OAuth Login Promise Hangs Indefinitely When User Closes Popup
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript, react
- Bereich
- authentication, frontend
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 171
- Forks
- 421
- Ø Merge
- 3 T. 6 Std.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus RocketChat/EmbeddedChat
-
Bug: username fallback in updateUserUsername never runs since the ddp-client migrationEvtl. vergeben @MuhammadFaizan-prog hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
RocketChat/EmbeddedChat#1489 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug]: Low contrast on color swatch borders in Theme Lab (Layout Editor)Evtl. vergeben @yashsarvaiya45 hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
RocketChat/EmbeddedChat#1486 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug(api): _doConnect swallows connection/auth errors and marks failed sessions as authenticatedEvtl. vergeben @ashwanisingh011 hat das vor 1 Tag übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
RocketChat/EmbeddedChat#1484 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: White screen crash (`Cannot read properties of undefined (reading 'members')`) when rendering UserMention outside MarkupInteractionContextEvtl. vergeben @swarnendusahu10-dotcom hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
RocketChat/EmbeddedChat#1482 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: UIKit PreviewBlock cover image tiles repeatedly and stretches across viewport when zoomed outEvtl. vergeben @swarnendusahu10-dotcom hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
RocketChat/EmbeddedChat#1480 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in RocketChat/EmbeddedChat
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Life-Framework/Life-Framework#7017 ·
Maintainer antworten meist innerhalb von 1 Tag
-
e/DevOps enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
Accenture/sfmc-devtools#2795 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent/guide documentation help wanted stage/010-actionable
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
kubestellar/console-kb#4003 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
FilOzone/synapse-sdk#1201 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag