Skip to content
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

Issue with version 9 compat build on Safari after one hour long sessions #5644

Closed
Krisell opened this issue Oct 20, 2021 · 6 comments · Fixed by #5664
Closed

Issue with version 9 compat build on Safari after one hour long sessions #5644

Krisell opened this issue Oct 20, 2021 · 6 comments · Fixed by #5664

Comments

@Krisell
Copy link

Krisell commented Oct 20, 2021

  • Operating System version: macOS and iOS
  • Browser version: Safari 14 and 15
  • Firebase SDK version: 9.1.3 compat
  • Firebase Product: auth

Description

Since updating from version 8.9.1 to the version 9.1.3 compatibility build, we started seeing lots of errors sent to our error tracker for Safari devices on sessions longer than one hour: undefined is not an object (evaluating 'e._canInitEmulator=!1')

I believe this is the following line in the source code:

(auth as AuthInternal)._canInitEmulator = false;

The error is only triggered in Safari (macOS and iOS), and only for sessions longer than one hour. The error seems to be triggered on the first Firebase action after the one hour mark (our error reports range from just a few seconds after one hour, up to several minutes, and normal flow in our application is one Firebase action at least every 5 minutes). None of the error reports show a session duration shorter than one hour.

Note that it's not one hour idle, but rather with continuous Firebase actions every 3-5 minutes without any issues.

So, something must happen after specifically one hour, for instance the requirement of a refresh-token exchange the seems to fail. If I haven't misunderstood anything, this should be handled internally by the Firebase SDK. We are using a custom token to authenticate the session to begin with, but that happens immediately and one hour prior to the triggered errors. We do know that custom tokens has an expiration of one hour, but your docs clarify that this is unrelated in the following sentence and that the Firebase sessions should function longer (which it also always has done previously): Note: this only controls the time when the custom token itself expires. But once you sign a user in using signInWithCustomToken(), they will remain signed in into the device until their session is invalidated or the user signs out.

Steps to reproduce:

As far as we know

  • On Safari 14 or 15, use Firebase Auth 9.1.3 compat.
  • Sign in using custom token (unknown if that is required)
  • Wait one hour and then perform an action that requires auth (in our case, it's trying to upload a file to Storage).

We had no similar problems with version 8, and we have not changed our code when transitioning to the compat build.

We are absolutely planning to migrate to the modular version of Firebase 9, but we have not been able to try that yet and we don't know if that would affect this problem.

Has any similar reports been sent, and do you immediately recognize the one hour "limit" for Safari sessions?

@google-oss-bot
Copy link
Contributor

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

@sam-gc
Copy link
Contributor

sam-gc commented Oct 20, 2021

Thanks for reaching out. This definitely sounds like a bug. So just to clarify:

  • You don't see this behavior in other browsers?
  • No auth actions are taken over the course of the hour? If you take one auth action say, 30 minutes in, does the issue still persist?

@Krisell
Copy link
Author

Krisell commented Oct 21, 2021

Thanks for the response.

Yes, this only shows in Safari for macOS and iOS. Our user base in general is mostly using Chrome, but this error is only triggered for Safari users (and Chrome on iOS, which uses the Safari engine).

Our app works in a way that signs the user in to Firebase automatically at the beginning using a custom token, and keeps that sign-in throughout the session. In case the user is logged out for any reason, we attempt a new sign-in using a new custom token. Actions are taken during the whole session, mostly Firebase storage uploads, but no additional auth action should need to happen on our end since the user is already signed in. We always check that the user is still signed in before any action using firebase.auth().currentUser.

We will try to perform manual testing of this today, and we will also temporarily revert production to Firebase 8.

@Krisell
Copy link
Author

Krisell commented Oct 21, 2021

I should add that we actually upgraded from 8.9.1 to 9.1.3, so we have not tested 8.10.0 and can't say if the problem was introduced there or in version 9.

@Krisell
Copy link
Author

Krisell commented Oct 21, 2021

We have now tested manually and after exactly one hour, all Storage and Firestore (the two services we use) operations stopped working, and the error mentioned above started to be thrown in the console.

@sam-gc
Copy link
Contributor

sam-gc commented Oct 21, 2021

Thank you very much for the details. We will do some investigation

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants