This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-31
Channels
- # aleph (12)
- # announcements (4)
- # asami (7)
- # babashka (20)
- # beginners (92)
- # calva (74)
- # clj-kondo (8)
- # cljdoc (70)
- # clojure (47)
- # clojure-dev (29)
- # clojure-europe (27)
- # clojure-nl (7)
- # clojure-norway (3)
- # clojurescript (7)
- # cursive (2)
- # datomic (1)
- # emacs (8)
- # events (5)
- # fulcro (36)
- # gratitude (4)
- # humbleui (25)
- # introduce-yourself (1)
- # lsp (26)
- # malli (6)
- # missionary (8)
- # nbb (50)
- # off-topic (9)
- # pathom (2)
- # pedestal (3)
- # portal (32)
- # practicalli (5)
- # reitit (5)
- # releases (1)
- # ring (6)
- # shadow-cljs (87)
- # sql (31)
- # tools-deps (26)
- # vim (3)
- # xtdb (15)
TypeError: PromiseResolve called on non-object at resolve (<anonymous>)
How can I lift a promise into a task in Clojurescript?
Thanks!this succeeds:
(tests
(def x (js/Promise.resolve "hi"))
((m/sp (tap (m/? (await-promise x))))
tap tap)
% := "hi"
% := "hi")
Looks like javascript black magic to me violating a cloroutine assumption related to the context of the interop call
call seems to need Promise.resolve.bind(Promise)
this passes
(defn f [x]
(js/Promise.resolve.call js/Promise x))
(tests
((m/sp (tap (m/? (await-promise (f "2")))))
tap tap)
% := "2"
% := "2")
this fails
(tests
((m/sp (tap (m/? (await-promise (js/Promise.resolve.call js/Promise "3")))))
tap tap)
% := "3"
% := "3")
FAIL in (generated__dustin_scratch_1) (:)
expected: (= % "3")
actual: (not (= #object[TypeError TypeError: cr48023_place_2.call is not a function] "3"))
so yeah looks to me like cloroutine gets the interop wrongindeed this is a cloroutine bug, thanks for reporting https://github.com/leonoel/cloroutine/issues/25