firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.83k stars 891 forks source link

Firebase Auth is failing on Safari 16.1 (destructuring error) #6636

Closed koush closed 2 years ago

koush commented 2 years ago

[REQUIRED] Describe the problem

Firebase UI does not work with Safari on Mac or iPhone.

Steps to reproduce:

  1. Go to https://fir-ui-demo-84a6c.firebaseapp.com/. This is the project's own login demo page.
  2. Try to log in on Mac or iPhone.
  3. Login hangs.

Additionally: these steps work fine with Chrome on the same Mac.

Relevant Code:

N/A

Seen in console:

TypeError: Right side of assignment cannot be destructured

 async onAuthEvent(event: AuthEvent): Promise<void> {
    // this line
    const { urlResponse, sessionId, postBody, tenantId, error, type } = event;
    if (error) {
      this.reject(error);
      return;
    }

The event it is receiving seems to be a window Message event, and not the JSON contained within data which is what contains the fields to be destructured.

image

Crosspost from https://github.com/firebase/firebaseui-web/issues/977

I believe the bug is in the js sdk as the relevant file is in this source file: https://github.com/firebase/firebase-js-sdk/blob/b6c231a282313aeda59c447c24f71fdad35240bc/packages/auth/src/core/strategies/abstract_popup_redirect_operation.ts#L86

From my understanding of the stack trace, I think the js sdk uses iframes to communicate, and there's some sort of message passing failure happening.

google-oss-bot commented 2 years ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

prameshj commented 2 years ago

I see this with Safari 16.0 too.. But the modular demo app and the auth-compat demo app from firebase-js-sdk are working ok for me.

Closing this and leaving the firebaseui issue open.

mmmulani commented 2 years ago

we're seeing the same issue with Safari 16.1 beta and we don't use firebaseui, only standard firebase-js-sdk.

koush commented 2 years ago

we're seeing the same issue with Safari 16.1 beta and we don't use firebaseui, only standard firebase-js-sdk.

I ended up using a workaround by managing the auth redirects myself. This also provides an offramp for firebase, if you're only using the js sdk for auth. https://github.com/firebase/firebaseui-web/issues/977#issuecomment-1272388412

sww314 commented 1 year ago

This should still be open. We are still seeing the issue.

samsargent commented 1 year ago

Can also confirm we're seeing this with just the firebase-js-sdk (not using firebaseui).

If it helps, switching tosignInWithPopup works. signInWithRedirect doesn't work.