OAuth Login Promise Hangs Indefinitely When User Closes Popup
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- javascript, react
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- JavaScript
- スター
- 171
- フォーク
- 421
- 平均マージ
- 3日 6時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RocketChat/EmbeddedChat のほかの issue
-
Bug: username fallback in updateUserUsername never runs since the ddp-client migration対応中かも @MuhammadFaizan-prog が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
RocketChat/EmbeddedChat#1489 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Low contrast on color swatch borders in Theme Lab (Layout Editor)対応中かも @yashsarvaiya45 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
RocketChat/EmbeddedChat#1486 ·
メンテナーはふだん 1 日以内に返信
-
bug(api): _doConnect swallows connection/auth errors and marks failed sessions as authenticated対応中かも @ashwanisingh011 が 1 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
RocketChat/EmbeddedChat#1484 ·
メンテナーはふだん 1 日以内に返信
-
Bug: White screen crash (`Cannot read properties of undefined (reading 'members')`) when rendering UserMention outside MarkupInteractionContext対応中かも @swarnendusahu10-dotcom が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
RocketChat/EmbeddedChat#1482 ·
メンテナーはふだん 1 日以内に返信
-
Bug: UIKit PreviewBlock cover image tiles repeatedly and stretches across viewport when zoomed out対応中かも @swarnendusahu10-dotcom が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
RocketChat/EmbeddedChat#1480 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
RocketChat/EmbeddedChat の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Life-Framework/Life-Framework#7017 ·
メンテナーはふだん 1 日以内に返信
-
e/DevOps enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
Accenture/sfmc-devtools#2795 ·
メンテナーはふだん 1 日以内に返信
-
agent/guide documentation help wanted stage/010-actionable
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
kubestellar/console-kb#4003 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
FilOzone/synapse-sdk#1201 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信