FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(router): reset internal state on error handler redirect after state commit by atscott · Pull Request #71130 · angular/angular · GitHub

Repository navigation

fix(router): reset internal state on error handler redirect after state commit - #71130

Merged
kirjs merged 1 commit into
angular:mainfrom
atscott:fix-redirect-after-commit
Oct 2, 2026
Merged

kirjs merged 1 commit into
angular:mainfrom
atscott:fix-redirect-after-commit

Conversation

atscott commented Oct 1, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

When an error occurs after BeforeActivateRoutes has already committed targetRouterState and withNavigationErrorHandler returns a RedirectCommand, the transition emits a redirecting NavigationCancel instead of NavigationError. Previously, StateManager skipped resetting internal state on all redirecting cancellations because redirects from guards and resolvers happen prior to BeforeActivateRoutes. This left the half-activated targetRouterState (whose unactivated routes do not yet have snapshot assigned) as the current routerState for the subsequent redirect navigation.

This change resets internal state if a redirecting cancellation occurs after targetRouterState was already committed.

Fixes #71126

ngbot Bot added this to the Backlog milestone Oct 1, 2026
atscott force-pushed the fix-redirect-after-commit branch from e8cc871 to 5009842 Compare October 1, 2026 19:44
atscott force-pushed the fix-redirect-after-commit branch from 5009842 to 2c0694f Compare October 1, 2026 19:51
atscott added the target: patch This PR is targeted for the next patch release label Oct 1, 2026
atscott force-pushed the fix-redirect-after-commit branch from 2c0694f to edd00af Compare October 1, 2026 19:55
…te commit

When an error occurs after `BeforeActivateRoutes` has already committed
`targetRouterState` and `withNavigationErrorHandler` returns a
`RedirectCommand`, the transition emits a redirecting `NavigationCancel`
instead of `NavigationError`. Previously, `StateManager` skipped resetting
internal state on all redirecting cancellations because redirects from guards
and resolvers happen prior to `BeforeActivateRoutes`. This left the uncommitted
or half-activated `targetRouterState` (whose unactivated routes do not yet have
`snapshot` assigned) as the current `routerState` for the subsequent redirect
navigation.

This change resets internal state if a redirecting cancellation occurs after
`targetRouterState` was already committed.

Fixes angular#71126
atscott force-pushed the fix-redirect-after-commit branch from edd00af to 654828d Compare October 1, 2026 20:12
atscott requested a review from alan-agius4 October 1, 2026 20:15

alan-agius4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Oct 2, 2026

atscott commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

kirjs merged commit f591d36 into angular:main Oct 2, 2026
25 checks passed

kirjs commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

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

Labels

action: merge The PR is ready for merge by the caretaker area: router target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Angular Router state committed before activation can make a valid error-handler redirect loop forever

3 participants


Back | FazBrowse Home | New Git URL