Bug: Incomplete logout leaves UI stuck in authenticated state when channel is missing or access is denied in ChatHeader.js
Maintainers usually reply within 1 day
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:
setIsUserAuthenticated(false)is never called, leaving the React UI permanently stuck in the authenticated view even though the backend session has been terminated.- Stores and UI state (
setMessages([]),setChannelInfo({}),setShowSidebar(false),setUserAvatarUrl(null), andisMessageLoaded) are not reset. - Additionally,
getChannelInfoandsetMessageAllowedlacktry...catchblocks and safe optional chaining (res?.success,res && 'errorType' in res), which can cause an unhandledTypeErrorcrash ifRCInstance.channelInfo()returnsundefinedor rejects on network failure.
Affected File
packages/react/src/views/ChatHeader/ChatHeader.js(lines 202–288)
Steps to Reproduce
- 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). - Observe the toast message:
"Channel doesn't exist. Logging out."or"You don't have permission to access this channel. Logging out". - Notice that while
RCInstance.logout()runs,isUserAuthenticatedremainstrueand the UI stays stuck in the logged-in state instead of returning to the login state.
Expected Behavior
- Error-triggered logouts in
getChannelInfoshould callawait handleLogout()so thatisUserAuthenticatedis set tofalseand all user/channel/message stores are properly cleared. - Async calls in
getChannelInfoandsetMessageAllowedshould 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RocketChat/EmbeddedChat
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
RocketChat/EmbeddedChat#1429 ·
Maintainers usually reply within 1 day
-
docs: README says Node 22 is required, but .nvmrc pins v24 and preinstall enforces itPossibly taken @Veerpratapgupta claimed this 29 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
RocketChat/EmbeddedChat#1377 · 1 comment ·
Maintainers usually reply within 1 day
-
test: isMessageSequential in layout_editor has no coverageMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
RocketChat/EmbeddedChat#1373 ·
Maintainers usually reply within 1 day
-
Permissions change-detection in useFetchChatData is dead — applyPermissions re-runs on every callPossibly taken @yash113gadia claimed this 166 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
RocketChat/EmbeddedChat#1317 ·
Maintainers usually reply within 1 day
-
Only the last emoji shortname in a message is converted to unicodePossibly taken @yash113gadia claimed this 166 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
RocketChat/EmbeddedChat#1315 ·
Maintainers usually reply within 1 day
All issues in RocketChat/EmbeddedChat
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Bug: Table layout and date column are cut off on mobile screens on the Tournaments -> History pageOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
hexlet-codebattle/codebattle#2375 ·
-
intake mcp-intake needs-human-review priority:high
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Ikalus1988/MisakaNet#5041 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nicobailon/pi-web-access#682 ·
Maintainers usually reply within 1 day
-
nip27: long hashtag swallows the rest of the content, lone # gives an empty hashtagPossibly taken @bardrop claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
nbd-wtf/nostr-tools#578 ·