[firebase_auth_web]: Make the Auth emulator persistence from #18926 configurable instead of hard-gated on kDebugMode

Aperta
#18,992 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@SelaseKay ci sta già lavorando.

Dal 25/11/2026.

  • #19013 di @SelaseKay — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
dart, firebase, flutter

Direzione di ricerca

Start from the two kDebugMode gates in packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart (restore on plugin init ~L60-75, remember-after-connect ~L565-600) and read the #18926 diff; the isAuthEmulatorDebugHost loopback check stays as is. Because the origin is reapplied inside Firebase.initializeApp, the flag must be readable before init: decide between a static on FirebaseAuth in the firebase_auth package (threaded through the platform interface) or a bool.fromEnvironment define, then have the web implementation read it. Done means the default still equals kDebugMode, profile builds can opt in, and existing web auth tests plus a new gate test pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Needs Attention platform: web plugin: auth type: enhancement
Which plugins/Platforms are affected?

Auth on Web

TL;DR

The fix from #18926 that keeps the Auth emulator across restarts is hard-gated on kDebugMode, so profile builds can't use it; please make that gate a setting, with a default of kDebugMode to keep existing behavior.

Description

#18926 (fixing #18888) keeps the Auth emulator origin across reloads and browser restarts, so a persisted user is never restored against production before useAuthEmulator runs. All of it is hard-gated on kDebugMode:

Request: replace those kDebugMode checks with a single setting whose default is kDebugMode, so nothing changes unless an app opts in. Because the origin is reapplied inside Firebase.initializeApp, the setting has to be readable before init, e.g. either:

// set before Firebase.initializeApp
FirebaseAuth.persistWebEmulatorOrigin = true; // default: kDebugMode

or a compile-time define:

const persist = bool.fromEnvironment(
  'FIREBASE_AUTH_PERSIST_EMULATOR',
  defaultValue: kDebugMode,
);

The existing loopback-host check (isAuthEmulatorDebugHost) would stay as it is.

Why is this important?

Profile builds are a normal way to test against the emulators. Debug can be too slow for canvas-heavy apps. In profile mode today:

  1. The persisted (anonymous) emulator user is restored from IndexedDB on startup.
  2. If its ID token is older than an hour, it is refreshed against securetoken.googleapis.com, which is production. With a referrer-restricted key, that fails with auth/requests-from-referer-http://localhost:<port>/-are-blocked.
  3. The later useAuthEmulator call fails with emulator-config-failed, silently outside debug, so Auth stays on production for the whole session, and Firestore on its emulator reports "client is offline".

The only way out is clearing site storage, which deletes the anonymous user and its emulator data every time.

Additional context and comments

firebase_core 5.2.0, firebase_auth 7.1.0, firebase_auth_web 6.4.0.
Related: #11233, #11534, #18689, #18888, #18926.

Lingua principale
Dart
Stelle
9.3k
Fork
4.1k
Merge medio
4g 17h
PR unite (30g)
49

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di firebase/flutterfire

Tutte le issue di firebase/flutterfire

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.