RocketChat / RocketChat/EmbeddedChat

Ghost Session: WebSocket Connection Leaks After Logout

Open
#1,158 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
165
Forks
381
Avg merge
1d 2h
Merged PRs (30d)
1

Description

The logout function in packages/api/src/EmbeddedChatApi.ts fails to disconnect the WebSocket client (this.rcClient). It only calls this.auth.logout(), which removes the authentication token but leaves the socket connection active. Consequently, the application continues to receive live messages and events for the previous session even after the user has visibly "logged out," leading to privacy leaks and inconsistent state if a new user logs in without a full page refresh.

Steps to reproduce:
  1. Login to EmbeddedChat and enter a room.
  2. Open the browser's Developer Tools and navigate to the Network tab.
  3. Filter by "WebSocket" to see the active connection.
  4. Call api.logout() or click the Logout button in the UI.
  5. Observe that the WebSocket connection remains active (status 101 Switching Protocols) and frames continue to be received.
Expected behavior:

Logout should fully terminate the session. The function must call this.rcClient.disconnect() and this.rcClient.unsubscribeAll() to clean up resources and stop receiving data.

Actual behavior:
Image

The WebSocket connection remains active, and the client continues to receive real-time updates for the logged-out user's session.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/api/src/EmbeddedChatApi.ts and inspect the logout function alongside the rcClient lifecycle. Reproduce the issue with the browser Network tab, then verify that logout ends the WebSocket and stops further session events after the cleanup calls described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, authentication, networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.