leonoel / missionary

A functional effect and streaming system for Clojure/Script
Eclipse Public License 2.0
630 stars 26 forks source link

possible infinite loop with `group-by` + `ap` #55

Closed leonoel closed 2 years ago

leonoel commented 2 years ago

@mjmeintjes via slack :

(m/ap
     (let [[g fl] (->> (m/seed [1 2 1 1 3 1])
                       (m/group-by (comp keyword str))
                       m/?=)
           i (m/?> fl)]
       (when (= g :2)
         (throw (ex-info "GROUP 2" {})))
       (println "GROUP" g "  VAL " i)
       [g i]))

When the first exception is thrown, the process is cancelled, then

  1. the next group is transferred
  2. group consumer is run
  3. group consumer is cancelled immediately, because parent process is in cancelled state
  4. group-by creates a new group for the unconsumed value, goto 1
leonoel commented 2 years ago

A viable solution would be to change group-by such that after the process is cancelled, cancelling any of its consumers has no effect.

leonoel commented 2 years ago

Fixed in b.26