missionary 2026-02-11

The wiki https://github.com/leonoel/missionary/wiki/Task-interop#turn-a-blocking-call-into-a-task this approach to converting a core.async channel to a task:

(defn <!
  [c] (doto (m/dfv) (->> (async/take! c))))
But:
(<! (async/chan))
Execution error (ClassCastException) at clojure.core.async/on-caller (async.clj:60).
class missionary.impl.Dataflow$Port cannot be cast to class clojure.lang.IObj (missionary.impl.Dataflow$Port and clojure.lang.IObj are in unnamed module of loader 'app')

Interesting. core.async expects the callback function to support metadata, but the dfv object does not. As a workaround we can pass a wrapper function :

(defn <! [c]
  (let [v (m/dfv)]
    (async/take! c #(v %))
    v))

👍 1

The right fix is probably to implement metadata support