Skip to content

Reset open subgroups when a subscription is cancelled - #299

Open
afrind wants to merge 1 commit into
mainfrom
fix/reset-open-subgroup-on-cleanup
Open

Reset open subgroups when a subscription is cancelled#299
afrind wants to merge 1 commit into
mainfrom
fix/reset-open-subgroup-on-cleanup

Conversation

@afrind

@afrind afrind commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

When a subscription's read loop is parked in readStreamData on an open subgroup, session cleanup could leak the open subgroup consumer: the transport may cancel the read handle without enqueuing an error, which the state-token await misses. cleanup() now cancels the subscribe state to wake the parked loop, and ObjectStreamCallback::isCancelled() no longer treats a cancelled subscription as terminal for an open subgroup, so the consumer still receives its owed reset() per the MoQConsumers contract.

This also applies to app-initiated unsubscribe(), which shares the same cancel() path: an open subgroup is now reset() on unsubscribe. Updated the Unsubscribe and UniControlDataStreamBeforeSetup tests to expect it, and added OpenSubgroupResetDuringSessionCleanup covering the cleanup case.


This change is Reviewable

When a subscription's read loop is parked in readStreamData on an open
subgroup, session cleanup could leak the open subgroup consumer: the
transport may cancel the read handle without enqueuing an error, which the
state-token await misses. cleanup() now cancels the subscribe state to wake
the parked loop, and ObjectStreamCallback::isCancelled() no longer treats a
cancelled subscription as terminal for an open subgroup, so the consumer
still receives its owed reset() per the MoQConsumers contract.

This also applies to app-initiated unsubscribe(), which shares the same
cancel() path: an open subgroup is now reset() on unsubscribe. Updated the
Unsubscribe and UniControlDataStreamBeforeSetup tests to expect it, and
added OpenSubgroupResetDuringSessionCleanup covering the cleanup case.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@afrind

afrind commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

Upstream facebookexperimental#202 is stalled. I will check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant