-
Notifications
You must be signed in to change notification settings - Fork 910
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
Auth not working properly in Safari: AbortError in indexeddb.ts #7888
Comments
I was looking through some old issues and it seems very similar to #6871 and #7272 Is it possible that a non-critical error for platform logging is is causing authentication to fail? cc @hsubox76 @dwyfrequency |
Thanks for bringing this issue to our attention @vthommeret. Let me check with the team if this issue is also related to #7829. |
Is this a warning or an error? Are they both in the same log or are these two separate logs? I'm asking because the line of code you're referring to should result in a |
Hi @hsubox76, thanks for the reply! They are two separate logs. I'm no longer seeing the error so it's possible it was a separate issue. I'm going to close this issue for now and will reopen if it reoccurs and I can get additional detail. Thanks! |
So this now re-appearing a few days later. Something I'm seeing is it may spin for up to a minute and occasionally it will finally authenticate. I'm also now seeing this when trying to sign in:
I haven't touched anything around sign in or authentication so I don't think this error is in my code. Same behavior as before — loading in Chrome or a private Safari window exhibits no issues. I've also disabled all my extensions which doesn't seem to have fixed anything. One interesting thing is quitting and reopening Safari seems to temporarily fix it. I'm not seeing the the AbortErrors or IndexedDB errors — it just seems like Firebase Auth is hanging / not returning auth status due to some state in Safari. |
Any update on this? I have the same issue |
OK I'm finally able to get a stack trace for the AbortError. It's a little hard to track down with all the anonymous functions but the Firebase call is here (the "transaction()" call):
async function readHeartbeatsFromIndexedDB(app) {
try {
const db = await getDbPromise();
const result = await db
.transaction(STORE_NAME) // Triggers AbortError
.objectStore(STORE_NAME)
.get(computeKey(app));
return result;
}
catch (e) {
if (e instanceof FirebaseError) {
logger.warn(e.message);
}
else {
const idbGetError = ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */, {
originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
});
logger.warn(idbGetError.message);
}
}
} It seems like this is very similar to the earlier uncaught heartbeat errors #6871 and #7272. That said it looks like errors are caught in that code so I'm not sure why this is still bubbling up and causing errors. The Firebase "transaction()" referenced above is line 625 in index.esm below. ![]() |
This may be fixed by #7890 - should make it into the next release. |
I've recently faced the same issue on 10.5.2 and the 10.7.2 release does not seem to fix it Edit: apparently Safari doesn't like |
If this is indeed the problem, we should be able to fix it quickly. Edit: Wait, I have more questions. (1) The first part of that generated key is (2) Does Safari have a problem with the |
Thanks to that stack trace though, it looks like the unhandled exception is being thrown at this point in the idb code (it says line 77 but I think it's here, maybe because we don't have the latest version of idb): That leads me to think that the problem in our code might be here: https://github.com/firebase/firebase-js-sdk/blob/master/packages/app/src/indexeddb.ts#L76 We await the result of Unfortunately, since this is hard to reproduce I can implement this "fix" but it will just be a shot in the dark and we won't know if it's related to the issue until someone who is having this issue tries it. I'll try to fix it and get it into next week's release. |
Here's the possible fix: #7984 |
@vthommeret do you have your app name set? e.g. |
@lukeromanowicz Can you clarify what error you're seeing? I.e. The abort error I shared? The primary key for Auth mostly works maybe half he time but I'm not sure how this is related. |
We can also confirm the issue still persists in version [1] https://firebase.google.com/docs/reference/js/auth.auth.md#authauthstateready |
@vthommeret I was randomly seeing the exact same error in Safari as you did and had |
We are also experiencing this issue, is there a recommended version that does not experience this issue? It is happening on Safari, intermittently. |
Hey faced the same issue with safari. Adding the application name to the initializeApp() function, and emptying the caches in safari developers tools fixed the issue |
This is a common error among our users, on both OSX and iOS Safari. I have not been able to reproducs it myself but get the errors reported via Sentry, so I can see that is affects many users. The exact error I'm seeing is:
|
Just wanted to add that this has nothing to do with firebase. In our project we use multiple indexeddb to store some info and it seems to be that some condition triggers wipe of db data. We haven't figured out what it is yet but all the dbs are still there, their tables are still there, but there's nothing in the tables. Clearing cache fully in Safari and reloading sometimes helps. |
Just another update. Not sure if it's relevant in this case but in our case this was only happening if you have dev tools enabled in Safari settings and after an hour, Safari in that case seems to wipe everything |
Thanks @jtovar2!! I fixed the issue using the above method too. |
Had the same issues on Safari, no problems with Chrome. The solution from @jtovar2 fixed things - just by adding a name to the // before
initializeApp(config)
// after
initializeApp(config, 'anyNameHere') |
I have triied the solution above (adding a name), but the error is still present, with iOS 17.5 and firebase 10.10 ; strange thing, the problem occurs only in iPhone, not in iPad this is my code:
|
I'm seeing the same issue, but it boggles me. I'm getting the firebaseLocalStorageDb created after login with google account via signInWithPopup. It's empty. it works fine in android/android pwa and in safari on osx and various other browsers across windows and Mac. |
Hey @vthommeret I'm trying to reproduce your issue, but your live demo seems to be down. Could you share more information to help me get a live demo running myself? I can't seem to reproduce it based off of just your snippet. Or, if possible, would you be able to make your demo live again? |
Hey @vthommeret. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Since there haven't been any recent updates here, I am going to close this issue. @vthommeret if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
Operating System
macOS 14.2
Browser Version
Safari 17.2
Firebase SDK Version
10.7.1
Firebase SDK Product:
Auth
Describe your project's tooling
Next.JS 14.0.4
Describe the problem
I'm running into an issue where neither
authStateReady
noronAuthStateChanged
is working consistently in Safari (i.e. 90% of the timeauthStateReady
never resolves oronAuthStateChanged
isn't called). It's a challenging bug because:I was able to track down when one of the errors occurred:
"Firebase: Error thrown when reading from IndexedDB. Original error: Error looking up record in object store by key range. (app/idb-get).
Unhandled Promise Rejection: AbortError: AbortError
I set a breakpoint and it appears that the error is coming from line 68 in
indexeddb.ts
:https://github.com/firebase/firebase-js-sdk/blob/f854abe5b9be5fa2edf0df9bea971e1cbf9a3746/packages/app/src/indexeddb.ts#L68C29-L68C29
One thing I've noticed is that in tabs where the page isn't working, if I look at IndexedDB there's no data in
firebase-heartbeat-storage
orfirebaseLocalStorageDb
but on the pages where it is working, there is data.I have a theory that there's a bug / some interaction with Safari's IndexedDB support, but I'm not sure what exactly. As you can imagine this bug is somewhat a showstopper since users can't log in :-)
Steps and code to reproduce issue
This is what I have for a minimal repro:
When auth works,
called authStateReady
is called, otherwise not. I have a live demo here: https://repro.easiestcourses.com/minimalIf it says
User: pending
then the bug is present. If it switched toUser: signed out
then it's working as expected. As I mentioned earlier, one challenging thing is that this doesn't happen consistently so that page may or may not work in Safari if you load it.The text was updated successfully, but these errors were encountered: