Skip to content

Commit 69d94e6

Browse files
fix(auth): stop beforeAuthStateChanged from holding the app unstable (#3770)
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 docs(auth): scope the beforeAuthStateChanged note to rc.1 and earlier Merging this change closes #3748, so the section's present-tense note would point at a closed issue. Also removed the false claim that the @angular/fire/auth import makes ng build hang: the guide registers the hook only in the browser, so its own build succeeds. The docs/auth.md change is left out, since it edits a section of the guide that 20.1.x does not have. (cherry picked from commit f182972)
1 parent 0fa01ea commit 69d94e6

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎src/auth/firebase.ts‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tools/build.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ ${exportedZoneWrappedFns}
139139
indexedDBLocalPersistence: null,
140140
prodErrorMap: null,
141141
multiFactor: null,
142+
// Its callback fires only on a sign-in or sign-out, so blocking would keep `ApplicationRef.isStable` false.
143+
beforeAuthStateChanged: { blockUntilFirst: false },
142144
linkWithCredential: { logLevel: LogLevel.VERBOSE },
143145
linkWithPhoneNumber: { logLevel: LogLevel.VERBOSE },
144146
linkWithPopup: { logLevel: LogLevel.VERBOSE },

0 commit comments

Comments
 (0)