Fork me on GitHub
#core-async
<
2019-06-14
>
dpsutton17:06:57

using core async in cljs, if i have the following mounted component:

(defn go-loop []
  (async/go-loop []
    (<! (async/timeout 1000))
    (when (exists? js/window.console)
      (js/console.log "can we do this?"))
    (recur)))

(defn init []
  (enable-console-print!)
  (go-loop)
  (r/render [:h3 "works in chrome but not IE"] (.getElementById js/document "app")))
this works in chrome and IE when the devconsole is open but throws in async impl when the console is closed.

dpsutton17:06:57

am i doing something I shouldn't? I get IO shouldn't happen from a go-loop but does that include a seemingly innocuous call to console log?

hiredman17:06:48

I don't really use cljs, but I think think all your names with dots in them for js stuff may cause you issues

hiredman17:06:37

e.g. (js/console.log ...) should maybe be (.log js/console ...)

dpsutton17:06:07

let me update

dpsutton17:06:30

wow i think that solved it. i thought those two forms were equivalent

hiredman17:06:24

I think it may happen to work sometimes

hiredman17:06:01

but I am really not sure, you might try checking out #clojurescript and see what they say about it

dpsutton17:06:55

i thought i had seen there was a "preference" for the (.log js/console ...) but thought they were equivalent. Either way thanks. I had been wondering how to strip it down to basic stuff and just didn't think about that

bronsa17:06:29

they're equivalent in cljs, but i suspect the cljs core.async analyzer is broken in that case, since it doesn't use the cljs analyzer but a hand rolled one

4
dpsutton17:06:42

the bug only happens in IE11 though