Interesting issue with stateful transducers and core.async here: https://github.com/cgrand/xforms/issues/37
It looks like there is a way to handle it: https://github.com/clojure/clojure/blob/clojure-1.10.1/src/clj/clojure/core.clj#L7160 as mentioned here https://ask.clojure.org/index.php/9529/infinite-loop-with-stateful-transducer-core-async-channel
but I suppose the question is "where is the right place to handle it?"
Another way to frame the question: are transducing contexts allowed to call the completing arity more than once? If yes it means that all “flushing” (that do stuff on completion) transducers must defend against extra calls.
The docs are quite explicit: A completing process must call the completion operation on the final accumulated value exactly once. https://clojure.org/reference/transducers
Seems like a core.async bug to me. But at least it works if you use promise-chan when you're only expecting one result (by works I mean calls the completion only once, repeating/infinite output from the channel is then as expected from promise-chan).
sorry, I have not fully read everything above. if there is a bug, please file a question at https://ask.clojure.org
There is: https://ask.clojure.org/index.php/9529/infinite-loop-with-stateful-transducer-core-async-channel
oh, thanks :)
I must have missed this when originally posted, I'll take a look at it when I have time