Skip to content

Commit 694cbdf

Browse files
committed
Wait for upto 5s for IDP sign in to finish, after popup is closed.
In some cases (Fiefox or mobile or if opener is an iframe), the popup is closed by the oauth helper code right after sign in has completed at the IDP. The IDP response still needs to be processed by the SDK + signInWithIdp API call needs to be invoked. This can take upto 7s, if there is a blocking function configured. Increase the poller timeout to 8s, so it does not reject the sign in with popup-closed-by-user error.
1 parent fb6df83 commit 694cbdf

File tree

1 file changed

+8
-3
lines changed
  • packages/auth/src/platform_browser/strategies

1 file changed

+8
-3
lines changed

packages/auth/src/platform_browser/strategies/popup.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ import { FederatedAuthProvider } from '../../core/providers/federated';
4646
import { getModularInstance } from '@firebase/util';
4747

4848
/*
49-
* The event timeout is the same on mobile and desktop, no need for Delay.
49+
* The event timeout is the same on mobile and desktop, no need for Delay. Set this to 8s since
50+
* blocking functions can take upto 7s to complete sign in, as documented in:
51+
* https://cloud.google.com/identity-platform/docs/blocking-functions#understanding_blocking_functions
52+
* https://firebase.google.com/docs/auth/extend-with-blocking-functions#understanding_blocking_functions
5053
*/
5154
export const enum _Timeout {
52-
AUTH_EVENT = 2000
55+
AUTH_EVENT = 8000
5356
}
5457
export const _POLL_WINDOW_CLOSE_TIMEOUT = new Delay(2000, 10000);
5558

@@ -282,7 +285,9 @@ class PopupOperation extends AbstractPopupRedirectOperation {
282285
if (this.authWindow?.window?.closed) {
283286
// Make sure that there is sufficient time for whatever action to
284287
// complete. The window could have closed but the sign in network
285-
// call could still be in flight.
288+
// call could still be in flight. This is specifically true for
289+
// Firefox or if the opener is in an iframe, in which case the oauth
290+
// helper closes the popup.
286291
this.pollId = window.setTimeout(() => {
287292
this.pollId = null;
288293
this.reject(

0 commit comments

Comments
 (0)