Skip to content

onAuthStateChanged gives the user after a long time on app reloads #8118

@stee1ix

Description

@stee1ix

Operating System

Android 14

Browser Version

React Native

Firebase SDK Version

10.10.0

Firebase SDK Product:

Auth, Firestore

Describe your project's tooling

Bare React Native

Describe the problem

When doing a fresh signInWithEmailAndPassword, the onAuthStateChanged fires and gives the user quickly, but after killing the app and starting again the persisted user takes 20-30secs to be returned, even on hot reloads. Has anyone experienced this issue as well. Please help, it's urgent.

Steps and code to reproduce issue

Listener:
onAuthStateChanged(auth, user => {
console.log(user);
if (user) {
setUser(user)
} else {
setUser(null);
}
});

Initialization:
const createFirebaseApp = () => {
let app;
let auth;
if (getApps().length === 0) {
app = initializeApp(config);
auth = initializeAuth(app, {
persistence: getReactNativePersistence(ReactNativeAsyncStorage)
});
} else {
app = getApp();
}

return { app, auth };
};
const { app, auth } = createFirebaseApp();

export const firestore = getFirestore(app);
export { auth };

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions