fix: detach a subscription's listeners when it ends - #437
Open
brainRottedCoder wants to merge 1 commit into
Open
brainRottedCoder wants to merge 1 commit into
brainRottedCoder wants to merge 1 commit into
Conversation
unsubscribe deleted the registry entry and left the callbacks registered on the stream name, so a stopped stream kept looking live. The entry now carries those callbacks, a re-established entry inherits them, and forgetSubscription detaches them. Closes RocketChat#396 Co-authored-by: Cursor <cursoragent@cursor.com>
This branch has not been deployed
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.
Summary
Ending a DDP subscription now releases the listeners it registered. The entry carries the callbacks its subscribers passed, a re-established entry inherits that list, and
forgetSubscriptiondetaches them. A stopped stream no longer looks live.Closes #396
Proposed changes
onStreamDataincluded, is not the record's and stays.Changes
writeSubscriptionrecords every callback on the entry, and a reopen inherits that list instead of registering again.subframe is built fromid,nameandparams, so the callback list cannot be serialized onto the wire.forgetSubscriptiondetaches the entry's callbacks. A function still listed by another entry on the same stream name stays attached.onEventon a handle whose stream has already ended attaches nothing.Test plan
npm run lintnpm run typechecknpx jest— 483 tests, 35 suites