Fork me on GitHub
Christian Johansen07:03:43

Is it possible to somehow clog up core.async on ClojureScript? I'm working with some CLJS code that runs on Node. I create a channel, then go through a promise chain to perform some async tasks (interoping with external libraries), then putting data to the channel, and finally closing it at the end of the chain. Currently this code blows up halfway through for reasons that I still haven't figured out, but after having tried this a few times in the REPL, core.async go blocks seemingly go dead

Christian Johansen07:03:05

after I've debugged my function (which doesn't work), I see this behavior:

Christian Johansen07:03:24

(cljs.core.async/go (println "Hello"))
cljs.user> Hello
cljs.user> (my-broken-fn)
... explosions ...
cljs.user> (cljs.core.async/go (println "Hello"))
cljs.user> (println "Is the REPL alive?")
cljs.user> Is the REPL alive?

Christian Johansen07:03:06

any ideas on how I might have landed myself in this situation, or what I can do to figure it out? can I probe core.async for pending operations somehow?


@christian767 In Clojure, go blocks pull from a small pool of threads. I'm not sure if the model is the same in CLJS (given that it's running in a single-threaded environment), but if the same abstraction exists you might have tied up all available threads. Do you have something in my-broken-fn that could be causing an infinite loop? Or waiting forever for blocking IO? That's usually what will cause that behavior for me in regular Clojure.


if you have a loop in a go block that never calls !>, <!, or one of the alts variants, it will never yield the js thread

Christian Johansen18:03:13

Hmm, that sounds like it might be it, thanks