missionary

J 2026-01-21T08:46:43.631749Z

Hi I started to rewrite an old JS app to ClojureScript and I use missionary to handle the async part. I'm wondering if this code is ok:

;; NodeJS server
(def app (express))

;; Main task
(defn ?do-something
  [req]
  (m/sp ...))

(.get app "/" (fn [req res)
                ((?do-something req)
                 (fn [ok] (.send res ok))
                 (fn [error] ...)))

Hendrik 2026-01-21T09:21:33.607499Z

Your code looks ok. Just pay attention, that you do not run blocking functions inside the tasks. use m/via for blocking stuff (jvm only).

J 2026-01-21T09:22:58.346619Z

m/via works on NodeJS?

Hendrik 2026-01-21T09:29:16.601059Z

oh. I did not read your message carefully enough. No it does not. via-call will throw.

Hendrik 2026-01-21T09:30:20.148259Z

however, I guess, that there shouldn’t be to many blocking apis on NodeJS. if there are any at all. So it should not be a problem.

xificurC 2026-01-21T09:45:38.075309Z

the idea is to compose async stuff as tasks/flows to benefit from the library's supervision. Ideally one ends up with a single task at the root of the application. Then yes, one has to initiate the root task as (root-task s f)

leonoel 2026-01-21T16:38:30.888419Z

this pattern is fine, but make sure the callbacks never throw

J 2026-01-21T16:45:18.265629Z

Ok. Thanks guys!