missionary 2026-01-21

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] ...)))

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

m/via works on NodeJS?

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

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.

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)

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