core-async

2019-03-04T07:28:43.003600Z

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

2019-03-04T07:29:05.004200Z

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

2019-03-04T07:30:24.004800Z

(cljs.core.async/go (println "Hello"))
#object[cljs.core.async.impl.channels.ManyToManyChannel]
cljs.user> Hello
cljs.user> (my-broken-fn)
... explosions ...
cljs.user> (cljs.core.async/go (println "Hello"))
#object[cljs.core.async.impl.channels.ManyToManyChannel]
cljs.user> (println "Is the REPL alive?")
cljs.user> Is the REPL alive?

2019-03-04T07:31:06.005500Z

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?

dtsiedel 2019-03-04T17:29:44.007500Z

@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.

2019-03-04T17:47:34.008400Z

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

2019-03-04T18:04:13.009700Z

Hmm, that sounds like it might be it, thanks