-
Notifications
You must be signed in to change notification settings - Fork 937
signInWithPopup issue with Firefox and beforeSignIn blocking function #6956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The popup closed error is thrown from here -
We will try to repro with the attached snippet(thanks!), but it might be a browser-specific behavior that we might not be able to detect/control in the SDK. |
Firebase SDK version: 9.15.0 I have been able to reproduce this error using chrome v 107.0.5304.87 When I updated to v 110.0.5481.100 - the error went away. Not sure if this is helpful - it's one data point more |
any updates on this? |
Thanks for the update. Are we still seeing this in the latest Firefox 110? As mentioned above, the SDK gets a popup closed event and reacts to it, so it likely has a browser interaction at play here. |
@prameshj Yes, I'm still seeing this issue. It seems like this might be an issue in After a little debugging I found this to be the current series of events:
If I monkey patch the javascript environment during the execution of This leads me to believe that the close event is being called by some code in It'd be interesting for someone with access to that code to see if there are any cases where it will close immediately or in the event of specific failures (e.g. the gapi iframe stuff isn't working, Firefox specific code paths, etc...). |
Haha, yeah, so when I installed https://addons.mozilla.org/en-US/firefox/addon/uaswitcher/ and just changed my user agent to Chrome it worked fine... 😢 So definitely some Firefox specific code path. |
Interesting.. thanks for sharing this. There isn't any user agent specific code in the /auth/handler.
Can you share the full URL to /__/auth/handler in the 2 cases? Thanks! |
See below:
https://{APP_NAME}.firebaseapp.com/__/auth/handler?apiKey={API_KEY}&appName=%5BDEFAULT%5D&authType=signInViaPopup&redirectUrl=https%3A%2F%2F{APP_NAME}.firebaseapp.com%2F%3F&v=9.15.0&eventId=8661282041&providerId=google.com&customParameters=%7B%22prompt%22%3A%22select_account%22%7D&scopes=profile
https://{APP_NAME}.firebaseapp.com/__/auth/handler?state={STATE}&code={CODE}&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&authuser=0&prompt=none
|
The window is definitely getting closed in
Someone with access to the source map should then be able to fairly quickly figure out what's going on. |
Thanks for the detailed analysis Silas! I wasn't able to go through the steps you provided, but I looked through the code and yes, we have some legacy SDK codepaths where the popup is closed by auth/handler and there is special case for Firefox. I believe this was because Firefox does not provide the opener with permissions to close the popup (or was the case few versions back). So, the auth/handler sends an AuthEvent and closes the popup. Meanwhile the main window, listens for AuthEvent and also polls for user cancellation in -
|
In the above code, once the poller detects that the window has been closed (will be the case for Firefox), it waits for 2s before throwing error -
|
The fix went out in [email protected] and seems to have resolved the issue, so I'm going to close this issue. Thanks @prameshj for working through it! |
Thank you so much for confirming this and for your detailed investigation, @silas ! |
Uh oh!
There was an error while loading. Please reload this page.
Describe your environment
Describe the problem
When
signInWithPopup
is used with Firefox (couldn't reproduce in Chrome or Safari) and there is abeforeSignIn
blocking function that takes longer than ~2 seconds to execute thesignInWithPopup
call will throw theauth/popup-closed-by-user
error.Steps to reproduce:
initializeApp
call inpublic/index.html
to contain valid settings<YOUR-NAME>.firebaseapp.com
in Firefox and clickSign in with Google
Firebase: Error (auth/popup-closed-by-user).
beforeSignIn
blocking function via Authentication -> Settings -> Blocking functionsRelevant Code:
Blocking function
HTML
Quickly looking through the js-sdk code, there seems to be a 2 second timeout here, which might be related:
firebase-js-sdk/packages/auth/src/platform_browser/strategies/popup.ts
Line 291 in 49ee786
firebase-js-sdk/packages/auth/src/platform_browser/strategies/popup.ts
Line 52 in 49ee786
Logs:
The text was updated successfully, but these errors were encountered: