missionary icon indicating copy to clipboard operation
missionary copied to clipboard

`ap` cancellation doesn't propagate to child branches

Open leonoel opened this issue 1 year ago • 3 comments

Slack thread : https://clojurians.slack.com/archives/CL85MBPEF/p1726679710600169

Repro :

(def ps
  ((m/ap
     (m/amb= 1 2 3)
     (try (m/? m/never)
          (catch missionary.Cancelled _
            (m/amb))))
   #(prn :step) #(prn :done)))

(ps)   ;; should print :done

leonoel avatar Sep 22 '24 15:09 leonoel

Does b40 fix this?

erichocean avatar Nov 14 '24 12:11 erichocean

No, it's still a bug

leonoel avatar Nov 14 '24 19:11 leonoel

Another possible example:

(defn with-final
  []
  (m/ap
   (m/amb=
    :start
    (try
      (m/? m/never)
      (catch missionary.Cancelled _ :end)))))

(defn merge-flows [& flows]
  (m/ap
   (m/?<
    (m/?> (count flows) (m/seed flows)))))

(comment
  (def cancel
    ((m/reduce prn nil (merge-flows (with-final)
                                    (with-final))) prn prn))

  (cancel) ;; prints end once
  (cancel) ;; prints end again!
   )

Thread: https://clojurians.slack.com/archives/CL85MBPEF/p1763154775780589?thread_ts=1763149125.436899&cid=CL85MBPEF

telekid avatar Nov 15 '25 18:11 telekid