RocketChat / RocketChat/EmbeddedChat

Bug: Inconsistent Logout Logic Causing State Leaks in ChatHeader

Open Beginner friendly
#1,081 0 comments 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

A frontend state management issue exists in ChatHeader.js where different logout paths are handled inconsistently. In certain error scenarios, the application directly calls RCInstance.logout() instead of using the centralized logout handler.

This results in the API session being terminated without clearing the internal React state, leaving stale messages and channel data in memory.


Observed Behavior

In failure scenarios such as:

  • Room Not Found
  • Not Allowed

The useEffect hook triggers a logout by calling:

RCInstance.logout();

However, this bypasses the main handleLogout function, which is responsible for clearing:

  • Messages store
  • Channel and room metadata
  • User avatar and user-specific state
  • Other global React stores

As a result, stale data remains in memory even after logout.

Image ---

Why This Is Incorrect

When a session is terminated due to an error or authorization failure:

  • The API session must be invalidated
  • All local application state must be cleared

By bypassing the shared logout logic, the application enters an inconsistent state where old data is still accessible after logout. This can cause privacy issues and broken UI behavior for subsequent sessions.


Steps to Reproduce

  1. Authenticate and enter a private channel.
  2. Simulate a Not Allowed response from the API for that room.
  3. Observe that RCInstance.logout() is invoked.
  4. Inspect the UI and application state.

Result:

  • User is logged out at the API level.
  • Messages and channel data from the private room remain visible in the UI or React stores.

Expected Behavior

All logout and session-termination paths should:

  • Use a unified logout handler
  • Clear both the API session and all internal React state
  • Ensure no data from the previous session remains accessible

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 ChatHeader.js, focusing on the useEffect paths for Room Not Found and Not Allowed and the centralized handleLogout function. Trace which stores handleLogout clears, then verify that every session-termination path clears the API session and local messages, channel data, avatar, and other user state without leaving stale data visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
authentication, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.