Skip to content

fix: await useAuthEmulator before completing Yust.initialize - #416

Open
CLNMR wants to merge 1 commit into
masterfrom
await-use-auth-emulator
Open

fix: await useAuthEmulator before completing Yust.initialize#416
CLNMR wants to merge 1 commit into
masterfrom
await-use-auth-emulator

Conversation

@CLNMR

@CLNMR CLNMR commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • FirebaseAuth.useAuthEmulator(host, port) returns a Future<void>; on web the underlying JS connectAuthEmulator doesn't take effect synchronously, so auth calls (e.g. signInWithMicrosoft) started before that future resolves hit production endpoints instead of the emulator.
  • Exposes a ready future on YustAuthService and awaits it from Yust.initialize, so callers can rely on the emulator being fully wired by the time initialization returns.
  • The Dart-only and mocked variants get a no-op ready to keep the interface symmetric.

Test plan

  • In a Flutter web host app that calls Yust.initialize(emulatorAddress: 'localhost', ...), federated sign-ins (Microsoft/Google) now hit http://localhost:9099/emulator/auth/handler... instead of the production OAuth handler at <authDomain>/__/auth/handler.
  • In a Dart-only host (e.g. backend services), Yust.initialize still completes immediately — ready is a pre-completed Future.value() there.
  • Mocked tests still pass.

🤖 Generated with Claude Code

FirebaseAuth.useAuthEmulator(host, port) returns a Future<void>. On web
the underlying JS connectAuthEmulator does not take effect synchronously,
so any auth call (e.g. signInWithMicrosoft) started before that future
resolves hits production endpoints instead of the emulator.

Expose a `ready` future on the auth services and await it from
Yust.initialize so callers can rely on the emulator being fully wired
when initialization returns. The Dart-only and mocked variants get a
no-op `ready` to keep the interface symmetric.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant