Open
Description
Operating System
macOS 15.3.2
Environment (if applicable)
Safari 18.3.1
Firebase SDK Version
11.5.0
Firebase SDK Product(s)
Auth
Project Tooling
React app
Detailed Problem Description
The Firebase SDK gets into an error state often where it logs:
Firebase: Error thrown when reading from IndexedDB. Original error: Error looking up record in object store by key range. (app/idb-get)
multiple times in the console.
This is always followed by several unhandled abort errors.
This issue can occur on initial page load. On page load, I call into Firebase auth before performing another network request.
Steps and code to reproduce issue
I have one firebaseConfig.tsx file:
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
const firebaseConfig = {
XXXXXX,
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
A class called NetworkUtils.tsx that waits on firebase auth when making a network request:
static async makeRequest(
....
): Promise<Response> {
let user = auth.currentUser;
if (!user && authType !== NetworkUtilsAuthType.NONE) {
// Wait for auth initialization only if currentUser is null
user = await NetworkUtils.waitForAuthInit();
}
The same file has a function to auth the user
static waitForAuthInit(): Promise<User | null> {
if (NetworkUtils.authInitialized) {
// Auth is initialized; return currentUser immediately
return Promise.resolve(auth.currentUser);
}
if (!NetworkUtils.authInitPromise) {
NetworkUtils.authInitPromise = new Promise((resolve, reject) => {
const unsubscribe = onIdTokenChanged(
auth,
(user) => {
unsubscribe();
NetworkUtils.authInitialized = true;
NetworkUtils.authInitPromise = null; // Reset for future calls
resolve(user);
},
(error) => {
unsubscribe();
NetworkUtils.authInitialized = true;
NetworkUtils.authInitPromise = null; // Reset for future calls
reject(error);
}
);
});
}
return NetworkUtils.authInitPromise;
}