From 789897c19e9d1001eca9f42f53392e12133a97b2 Mon Sep 17 00:00:00 2001 From: Armando Navarro Date: Thu, 24 Sep 2026 20:19:04 -0700 Subject: [PATCH] fix(auth): stop beforeAuthStateChanged from holding the app unstable AngularFire wrapped beforeAuthStateChanged so that registering the hook added a pending task, cleared only when the callback first runs. Firebase runs that callback only on a sign-in or sign-out, so for a visitor who does neither the app never became stable. Registered on the server, it failed ng build during route extraction and left server-rendered requests without a response. This restores the blockUntilFirst: false override from #3590, which #3613 dropped without comment while adding log-level overrides next to it. The callback still runs inside Angular's zone and injection context, and its returned promise still reaches Firebase, so a rejection still cancels the sign-in. A call outside an injection context now logs its per-call warning only at the verbose level, as onMessage does. Fixes #3748 --- src/auth/firebase.ts | 2 +- tools/build.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/auth/firebase.ts b/src/auth/firebase.ts index 743ca90d8..5d359e54d 100644 --- a/src/auth/firebase.ts +++ b/src/auth/firebase.ts @@ -58,7 +58,7 @@ import { } from 'firebase/auth'; export const applyActionCode = ɵzoneWrap(_applyActionCode, true); -export const beforeAuthStateChanged = ɵzoneWrap(_beforeAuthStateChanged, true); +export const beforeAuthStateChanged = ɵzoneWrap(_beforeAuthStateChanged, false); export const checkActionCode = ɵzoneWrap(_checkActionCode, true); export const confirmPasswordReset = ɵzoneWrap(_confirmPasswordReset, true, 2); export const connectAuthEmulator = ɵzoneWrap(_connectAuthEmulator, true); diff --git a/tools/build.ts b/tools/build.ts index 2e5b2964f..46a1ed370 100644 --- a/tools/build.ts +++ b/tools/build.ts @@ -177,6 +177,8 @@ ${exportedZoneWrappedFns} indexedDBLocalPersistence: null, prodErrorMap: null, multiFactor: null, + // Its callback fires only on a sign-in or sign-out, so blocking would keep `ApplicationRef.isStable` false. + beforeAuthStateChanged: { blockUntilFirst: false }, linkWithCredential: { logLevel: LogLevel.VERBOSE }, linkWithPhoneNumber: { logLevel: LogLevel.VERBOSE }, linkWithPopup: { logLevel: LogLevel.VERBOSE },