Fix multicast subscriber cancellation and document shared ownership - #66
Merged
Merged
Conversation
twittemb
force-pushed
the
codex/fix-multicast-consumer-lifetime
branch
from
October 3, 2026 11:45
83b8327 to
3cde907
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a subscriber was cancelled while the shared upstream was suspended, multicast kept that subscriber waiting for an upstream value before it could finish. Upstream demand now runs under the shared sequence's ownership while each subscriber awaits its own cancellable subject channel.
Documents the other cause of #31's crash: creating a fresh
multicast/sharewrapper for every call creates multiple upstream iterators. The README includes a connection that stores and returns one shared instance; no global deduplication or cross-instance sharing is added.Validation: reproduced the cancellation hang before the fix; regressions cover cancellation without cancelling the shared stream and two consumers of the cached connection. All 175 tests pass on Swift 6.4/macOS, including concurrent delivery ordering and finish/failure tests.
Fixes #31.