fix(auth): stop beforeAuthStateChanged from holding the app unstable - #3770
Open
armando-navarro wants to merge 1 commit into
Open
armando-navarro wants to merge 1 commit into
armando-navarro wants to merge 1 commit into
Conversation
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 angular#3590, which angular#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 angular#3748
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3748
Restores
beforeAuthStateChanged: { blockUntilFirst: false }, which #3590 added and #3613 dropped without comment.Changes
@angular/fire/authwrapsbeforeAuthStateChangedwithblockUntilFirstset totrue, so registering the hook adds a pending task that clears only when the callback first runs. Firebase runs this callback only on a sign-in or sign-out, so for a visitor who does neither, the app never becomes stable.ApplicationRef.whenStable()never resolves.ng buildfails during route extraction, and a server that renders per request never responds.onMessagedoes.beforeAuthStateChangedshould not block". zone log verbosity #3613 removed it at the spot where it added log-level overrides, and none of the issues zone log verbosity #3613 fixed involve this function, so the removal looks accidental.docs/auth.mdand the sample keep importingbeforeAuthStateChangedfromfirebase/authuntil a release carries this fix.Verification
On an Angular 21.2 server-rendered app, comparing
21.0.0-rc.1with a build of this branch:ng buildon rc.1 fails after 34 seconds withRoutes extraction was aborted. TimeoutError. With this branch it succeeds.docs/auth.md, which registers the hook only in the browser: on rc.1 the app did not become stable within 10 seconds. With this branch it became stable after 25 milliseconds.npm run test:node: 331 specs, 0 failures.npm run test:chrome-headless: 107 passed, 48 skipped.