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: close the socket opened to log out of a removed workspace - #7918
Removing a workspace from the workspace switcher logs out of it with a short-lived SDK client. That client opens a DDP WebSocket for the login, but nothing ever closed it. The socket stayed open for the rest of the app's life, and after any network drop it reconnected to the removed workspace every few seconds.
logoutFromServer now creates the client before the try and always calls disconnect() in a finally, on success and when login, push.token or logout fails. The SDK's disconnect() cancels any scheduled reopen, so the socket stays closed.
Open the workspace switcher (tap the rooms list header) and long-swipe the other workspace to delete it.
Wait a minute, toggle airplane mode on and off.
Inspect the app's TCP connections (/proc/net/tcp on a rooted emulator, filtered by the app's uid).
Before: a new connection to the removed workspace opens once the network returns. After: none.
Run on an Android emulator (Pixel, API 34, debug build). Removed workspace: mobile.qa.rocket.chat (resolves to 52.23.78.116); kept workspace: open.rocket.chat. Each row is a count of the app's ESTABLISHED sockets to that address.
Before the fix:
== 60s after removal
2 104.20.22.143:443 open.rocket.chat
2 52.23.78.116:443 mobile.qa.rocket.chat
== airplane mode on
(no remote sockets)
== 40s after airplane mode off
2 172.66.161.172:443 open.rocket.chat
1 52.23.78.116:443 mobile.qa.rocket.chat <- reconnected to the removed workspace
With the fix:
== 60s after removal
2 104.20.22.143:443 open.rocket.chat
1 172.66.161.172:443 open.rocket.chat
1 52.23.78.116:443 mobile.qa.rocket.chat <- idle connection from before the removal
== airplane mode on
(no remote sockets)
== 40s after airplane mode off
2 104.20.22.143:443 open.rocket.chat <- nothing to the removed workspace
Local Metro and other non-workspace sockets are left out of both listings.
Screenshots
Types of changes
Bugfix (non-breaking change which fixes an issue)
Improvement (non-breaking change which improves a current function)
New feature (non-breaking change which adds functionality)
Documentation update (if none of the other choices apply)
I have added tests that prove my fix is effective or that my feature works (if applicable)
I have added necessary documentation (if applicable)
Any dependent changes have been merged and published in downstream modules
Further comments
Nothing changes on screen, so there is no video; the socket listings above are the evidence. The two new tests in logout.test.ts fail without the change: one covers the success path, one a failing login.
Summary by CodeRabbit
Bug Fixes
Improved cleanup when removing a server: its connection is disconnected even if signing in with a saved session token fails.
The connection is also disconnected after logout or if another cleanup step encounters an error, helping prevent connections from being left open.
No actionable comments were generated in the recent review.
Walkthrough
logoutFromServer now disconnects its workspace client in a finally block and logs disconnect failures. Tests cover resume-token login and verify that disconnection still occurs when login rejects.
Changes
Workspace logout
Layer / File(s)
Summary
Workspace logout and cleanup app/lib/methods/logout.ts, app/lib/methods/__tests__/logout.test.ts
logoutFromServer disconnects its workspace client in finally and logs disconnect failures. Tests verify that removed-workspace logout uses the stored resume token and disconnects after success or login failure.
Removing a workspace now closes the short-lived connection used to log out of it, so the removed workspace should no longer reconnect after a network drop. Tests cover disconnect after a successful logout and after a failed login. No remaining merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: logoutFromServer now closes the short-lived SDK socket opened to log out of a removed workspace. The raw summary confirms the disconnect in a finally block and the rel…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: logoutFromServer now closes the short-lived SDK socket opened to log out of a removed workspace. The raw summary confirms the disconnect in a finally block and the related test coverage. The title is specific and matches the changeset.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Errors were encountered while retrieving linked issues.
Errors: 1
JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 2820c7da-ce34-4bda-83ef-3fa4015c8447
Commits
Reviewing files that changed from the base of the PR and between f79425c and 887f95c.
Files selected for processing: 1
app/lib/methods/__tests__/logout.test.ts
Files with no reviewable changes: 1
app/lib/methods/tests/logout.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
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.
Proposed changes
Removing a workspace from the workspace switcher logs out of it with a short-lived SDK client. That client opens a DDP WebSocket for the
login, but nothing ever closed it. The socket stayed open for the rest of the app's life, and after any network drop it reconnected to the removed workspace every few seconds.logoutFromServernow creates the client before thetryand always callsdisconnect()in afinally, on success and whenlogin,push.tokenorlogoutfails. The SDK'sdisconnect()cancels any scheduled reopen, so the socket stays closed.Issue(s)
https://rocketchat.atlassian.net/browse/NATIVE-1848
How to test or reproduce
/proc/net/tcpon a rooted emulator, filtered by the app's uid).Run on an Android emulator (Pixel, API 34, debug build). Removed workspace: mobile.qa.rocket.chat (resolves to 52.23.78.116); kept workspace: open.rocket.chat. Each row is a count of the app's ESTABLISHED sockets to that address.
Before the fix:
With the fix:
Local Metro and other non-workspace sockets are left out of both listings.
Screenshots
Types of changes
Checklist
Further comments
Nothing changes on screen, so there is no video; the socket listings above are the evidence. The two new tests in
logout.test.tsfail without the change: one covers the success path, one a failinglogin.Summary by CodeRabbit