firebase / firebase/firebase-js-sdk

setPersistence(Auth.Persistence.LOCAL) Promise hangs, onIdTokenChanged/onAuthStateChanged never fire (mainly iOS, Firebase JS 8.10.1)

Open
#9,132 10 comments 3 reactions 0 assignees View on GitHub
api: auth needs-attention question Repro Needed stack:Cordova-Ionic stack:React
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### Operating System

Primarily observed on iOS devices in production (Ionic 5 + Capacitor 6 + React 17)

### Environment (if applicable)

Mobile: iOS (sporadic, seen in logs and user reports) and Framework: Ionic 5, Capacitor 6, React 17

### Firebase SDK Version

8.10.1

### Firebase SDK Product(s)

Auth

### Project Tooling

Ionic 5, Capacitor 6, React 17

### Detailed Problem Description

Some users mainly on iOS as currently seen in our logs get stuck on the loading screen when opening the app.
• The ‎`onIdTokenChanged` and ‎`onAuthStateChanged` callbacks never fire (no logs output).
• Wrapping ‎`setPersistence(Auth.Persistence.LOCAL)` with ‎`.then`/‎`.catch` logs shows neither handler runs—the Promise remains pending.
• ‎`firebase.auth().currentUser` is logged right before the listener is attached, confirming the code path is reached.
• This appears related to IndexedDB, which ‎`setPersistence(LOCAL)` relies on. If IndexedDB open hangs (possibly more likely on iOS), the Promise never resolves and authentication events do not fire.

Example code:this.firebaseAuth
.setPersistence(Auth.Persistence.LOCAL)
.then(() => console.log('[Auth] persistence set')) // never prints
.catch(err => console.error('[Auth] persistence error', err)); // never prints

Reproducibility:
• Sporadic in production, mainly on iOS; not yet reproduced internally

### Steps and code to reproduce issue

1. Use Firebase JS SDK 8.10.1 in an Ionic 5 + Capacitor 6 + React 17 app.
2. Call ‎`setPersistence(Auth.Persistence.LOCAL)` before setting up auth listeners.
3. For some iOS users, the Promise never resolves or rejects, and callbacks for ‎`onIdTokenChanged`/‎`onAuthStateChanged` never fire.
4. No error is logged, and the app remains stuck on the loading screen.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.