OAuth Login Promise Hangs Indefinitely When User Closes Popup

オープン
#1,474 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@SatyamPandey-07 がすでに取り組んでいます。

2026年11月29日 から。

  • #1475 @SatyamPandey-07 による — オープン

評価

難易度
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

  1. Configure EmbeddedChat with authFlow: 'OAUTH'.
  2. Click the Join / Sign in with Rocket.Chat OAuth button (triggers onJoin in packages/react/src/views/ChatInput/ChatInput.js, which calls await RCInstance.auth.loginWithRocketChatOAuth()).
  3. Close the opened OAuth popup window manually without completing authentication.
  4. Observe that the await never 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 reject to the Promise executor and track a settled flag to prevent double-settlement.
  • Extract a shared cleanup() helper to call clearInterval(checkInterval) and window.removeEventListener("message", onMessage).
  • Call cleanup() and reject(new Error("OAuth popup closed by user")) when popup.closed is detected before settlement.
  • Call cleanup() immediately when rc-oauth-callback resolves, and use e.data?.type === "rc-oauth-callback" to guard against null/non-object postMessage payloads.
主要言語
JavaScript
スター
171
フォーク
421
平均マージ
3日 6時間
マージ済み PR(30日)
4

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RocketChat/EmbeddedChat のほかの issue

RocketChat/EmbeddedChat の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。