OAuth Login Promise Hangs Indefinitely When User Closes Popup
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, react
- Ambito
- authentication, frontend
Direzione di ricerca
Start with packages/auth/src/loginWithRocketChatOAuth.ts, especially getRocketChatOAuthCredentials and its popup polling and message listener. Check the existing auth tests for coverage of OAuth popup callbacks and cancellation. Done when closing the popup rejects the promise, callback handling cleans up its listeners and interval, and malformed message data does not cause an error.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
When authenticating via loginWithRocketChatOAuth(), getRocketChatOAuthCredentials in packages/auth/src/loginWithRocketChatOAuth.ts creates a Promise that only accepts resolve and never rejects if the user closes the OAuth popup window manually. Additionally, e.data.type is accessed without optional chaining and the interval/event listener are not immediately cleaned up when rc-oauth-callback is received.
Steps to Reproduce
- Configure EmbeddedChat with
authFlow: 'OAUTH'. - Click the Join / Sign in with Rocket.Chat OAuth button (triggers
onJoininpackages/react/src/views/ChatInput/ChatInput.js, which callsawait RCInstance.auth.loginWithRocketChatOAuth()). - Close the opened OAuth popup window manually without completing authentication.
- Observe that the
awaitnever resolves or rejects, and no error toast or recovery state is triggered.
Expected Behavior
Closing the OAuth popup before authentication completes should clean up the polling interval and message event listener and reject the returned Promise with a descriptive error (e.g., "OAuth popup closed by user"), allowing callers' try/catch blocks to handle the cancellation.
Actual Behavior / Error Logs
No error is thrown; `getRocketChatOAuthCredentials` in `packages/auth/src/loginWithRocketChatOAuth.ts` (lines 45-67) clears `checkInterval` and removes the `message` listener when `popup.closed` is true, leaving the Promise permanently in a `pending` state.
Proposed Fix
Update getRocketChatOAuthCredentials in packages/auth/src/loginWithRocketChatOAuth.ts:
- Add
rejectto thePromiseexecutor and track asettledflag to prevent double-settlement. - Extract a shared
cleanup()helper to callclearInterval(checkInterval)andwindow.removeEventListener("message", onMessage). - Call
cleanup()andreject(new Error("OAuth popup closed by user"))whenpopup.closedis detected before settlement. - Call
cleanup()immediately whenrc-oauth-callbackresolves, and usee.data?.type === "rc-oauth-callback"to guard against null/non-objectpostMessagepayloads.
- Lingua principale
- JavaScript
- Stelle
- 171
- Fork
- 421
- Merge medio
- 3g 6h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RocketChat/EmbeddedChat
-
Bug: username fallback in updateUserUsername never runs since the ddp-client migrationForse già presa @MuhammadFaizan-prog l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
RocketChat/EmbeddedChat#1489 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Low contrast on color swatch borders in Theme Lab (Layout Editor)Forse già presa @yashsarvaiya45 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
RocketChat/EmbeddedChat#1486 ·
I maintainer di solito rispondono entro 1 giorno
-
bug(api): _doConnect swallows connection/auth errors and marks failed sessions as authenticatedForse già presa @ashwanisingh011 l’ha presa 1 giorno fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
RocketChat/EmbeddedChat#1484 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug: White screen crash (`Cannot read properties of undefined (reading 'members')`) when rendering UserMention outside MarkupInteractionContextForse già presa @swarnendusahu10-dotcom l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
RocketChat/EmbeddedChat#1482 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug: UIKit PreviewBlock cover image tiles repeatedly and stretches across viewport when zoomed outForse già presa @swarnendusahu10-dotcom l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
RocketChat/EmbeddedChat#1480 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di RocketChat/EmbeddedChat
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
[Docs] CONTRIBUTING.md links to retired GitHub Learning Lab and Try Git sitesForse già presa @adityamukesh l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
reillywalter/win-dev-doctor#92 ·
I maintainer di solito rispondono entro 1 giorno
-
[Feature] 新增「查看完整听歌设备记录」接口Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100