You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(realtime): preserve replacement channels during stale cleanup - #2803
Remove a realtime channel by object identity instead of topic. Repeating cleanup on an old channel now leaves a newly subscribed channel with the same topic registered and connected.
Why was this change needed?
An old channel's close callback can run again after its replacement has joined. Filtering by topic removes the replacement from getChannels() and schedules a disconnect, interrupting the active subscription. The underlying Phoenix socket already removes only the specific channel instance.
📸 Screenshots/Examples
The regression joins a channel, unsubscribes it, then joins a replacement with the same topic. Calling either old.unsubscribe() or client.removeChannel(old) again must preserve the replacement. Both cases fail before this fix.
The tests also verify distinct join references, broadcast delivery after the disconnect deadline, and normal disconnection when the replacement is finally removed.
Realtime, SDK, and dependency builds passed. Typechecks passed with --skipSync to bypass a project-reference sync gate; no configuration changes are included.
A separate smoke test against the built createClient API passed both cleanup cases using a mock WebSocket server.
Formatting and git diff --check passed. Package lint failed; comparing the changed files with the base checkout shows the same 20 source and 3 test diagnostics, with none added by this change.
Live Supabase service integration was not run because Docker is unavailable locally. The SDK unit runner reports disconnect-timeout open handles but exits successfully.
Implementation and independent review were AI-assisted.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Summary
Summary by CodeRabbit
Bug Fixes
Removing an unsubscribed channel no longer removes a replacement channel using the same topic. The replacement continues receiving broadcasts, and connection behavior remains correct.
RealtimeClient._remove now removes a channel by object identity instead of topic. Regression tests cover repeated unsubscribe and removal of an old channel after a replacement subscribes to the same topic. They verify the replacement remains registered, receives broadcasts, and prevents a deferred disconnect until it is removed.
Priority: Normal
Change: Bug fix
Merge Risk: Minimal · up to 0b6b0
No actionable merge-blocking risk is established for the channel-cleanup change. It is mergeable subject to normal checks.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint install timed out. The project may have too many dependencies for the sandbox.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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
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.
🔍 Description
What changed?
Remove a realtime channel by object identity instead of topic. Repeating cleanup on an old channel now leaves a newly subscribed channel with the same topic registered and connected.
Why was this change needed?
An old channel's close callback can run again after its replacement has joined. Filtering by topic removes the replacement from
getChannels()and schedules a disconnect, interrupting the active subscription. The underlying Phoenix socket already removes only the specific channel instance.📸 Screenshots/Examples
The regression joins a channel, unsubscribes it, then joins a replacement with the same topic. Calling either
old.unsubscribe()orclient.removeChannel(old)again must preserve the replacement. Both cases fail before this fix.The tests also verify distinct join references, broadcast delivery after the disconnect deadline, and normal disconnection when the replacement is finally removed.
🔄 Breaking changes
📋 Checklist
pnpm nx formatfor the changed files📝 Additional notes
Validation on Node 24 and pnpm 11.1.2:
--skipSyncto bypass a project-reference sync gate; no configuration changes are included.createClientAPI passed both cleanup cases using a mock WebSocket server.git diff --checkpassed. Package lint failed; comparing the changed files with the base checkout shows the same 20 source and 3 test diagnostics, with none added by this change.Live Supabase service integration was not run because Docker is unavailable locally. The SDK unit runner reports disconnect-timeout open handles but exits successfully.
Implementation and independent review were AI-assisted.