Welcome! Please see the About page for a little more info on how this works.

+1 vote
in core.async by

(let [closed (doto (a/chan) a/close!)
      open (a/chan)]
  (a/go-loop []
    (a/alts! [open [closed true]] :priority true)


Exception in thread "async-dispatch-1" java.lang.AssertionError: Assert failed: No more than 1024 pending takes are allowed on a single channel.
(< (.size takes) impl/MAX-QUEUE-SIZE)
    at clojure.core.async.impl.channels.ManyToManyChannel.take_BANG_(channels.clj:235)
    at clojure.core.async$do_alts$fn__8030.invoke(async.clj:253)
    at clojure.core.async$do_alts.invokeStatic(async.clj:245)
    at clojure.core.async$do_alts.invoke(async.clj:237)

my analysis is that when a write is attempted on a closed channel the handler should be commited, so as to allow cleanup of the handler registrations on other channels.

See https://github.com/clojure/core.async/blob/822920a45e5ea7fa28641922559fdeb888c15d05/src/main/clojure/clojure/core/async/impl/channels.clj#L74-L75

3 Answers

0 votes

Comment made by: cgrand

Attached patch

0 votes

Comment made by: tdg5

Thanks for documenting and offering a patch for this defect, Christophe!

Is there something blocking further action on this defect/patch? Is there anything I can do to help move a fix forward?

I can confirm the existence of this defect and that the attached patch remedies the problem. I can also confirm that all tests pass with the attached patch applied to the latest revision of core.async (https://github.com/clojure/core.async/commit/196f87dc21f55f601c867b796a0a421550b43c8f).

In the system I encountered this bug on, the actual root problem was that the channel being put to was being closed prematurely. In fact, if this bug didn't exist, my team probably wouldn't have noticed the put channel being closed prematurely (in fact, we didn't notice for months until the right circumstances arose). Perhaps obscuring such problems is part of the reason the suggested patch hasn't been accepted?

Any suggestions for actionable next steps are appreciated.

0 votes
Reference: https://clojure.atlassian.net/browse/ASYNC-204 (reported by cgrand)