Bug: Incomplete logout leaves UI stuck in authenticated state when channel is missing or access is denied in ChatHeader.js

Open
#1,427 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@yashsarvaiya45 is already working on this.

Since Nov 15, 2026.

  • #1428 by @yashsarvaiya45 — open

Assessment

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

Research direction

Start in packages/react/src/views/ChatHeader/ChatHeader.js at getChannelInfo (lines 202–288) and compare its two error branches with handleLogout() in the same file, noting which state resets are skipped. Also inspect the unguarded RCInstance.channelInfo() and setMessageAllowed paths. Done means both error branches reach the logout state reset and null/rejected responses are handled; verify by authenticating with a non-existent roomId. A linked open pull request (#1428) already covers this work, so read it before starting.

Written by the indexing model from the issue text.

Description

Description

In packages/react/src/views/ChatHeader/ChatHeader.js, when getChannelInfo encounters an 'error-room-not-found' or 'Not Allowed' error, it dispatches an error toast ("Logging out") and calls await RCInstance.logout() directly instead of invoking handleLogout().

Because handleLogout() is bypassed:

  1. setIsUserAuthenticated(false) is never called, leaving the React UI permanently stuck in the authenticated view even though the backend session has been terminated.
  2. Stores and UI state (setMessages([]), setChannelInfo({}), setShowSidebar(false), setUserAvatarUrl(null), and isMessageLoaded) are not reset.
  3. Additionally, getChannelInfo and setMessageAllowed lack try...catch blocks and safe optional chaining (res?.success, res && 'errorType' in res), which can cause an unhandled TypeError crash if RCInstance.channelInfo() returns undefined or rejects on network failure.
Affected File
  • packages/react/src/views/ChatHeader/ChatHeader.js (lines 202–288)
Steps to Reproduce
  1. Authenticate into EmbeddedChat configured with a non-existent roomId (error-room-not-found) or a restricted private room where the user lacks permission (Not Allowed).
  2. Observe the toast message: "Channel doesn't exist. Logging out." or "You don't have permission to access this channel. Logging out".
  3. Notice that while RCInstance.logout() runs, isUserAuthenticated remains true and the UI stays stuck in the logged-in state instead of returning to the login state.
Expected Behavior
  • Error-triggered logouts in getChannelInfo should call await handleLogout() so that isUserAuthenticated is set to false and all user/channel/message stores are properly cleared.
  • Async calls in getChannelInfo and setMessageAllowed should safely guard against null/undefined responses and network rejections.
Dominant language
JavaScript
Stars
170
Forks
397
Avg merge
12d 14h
Merged PRs (30d)
6

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

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.

More from RocketChat/EmbeddedChat

All issues in RocketChat/EmbeddedChat

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.