René's URL Explorer Experiment


Title: Angular Router state committed before activation can make a valid error-handler redirect loop forever · Issue #71126 · angular/angular · GitHub

Open Graph Title: Angular Router state committed before activation can make a valid error-handler redirect loop forever · Issue #71126 · angular/angular

X Title: Angular Router state committed before activation can make a valid error-handler redirect loop forever · Issue #71126 · angular/angular

Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description An app that sends navigation failures to an error page the documented way never finishes the redirect: withNavigationErrorHandler(() => ne...

Open Graph Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description An app that sends navigation failures to an error page the documented way never finishes the redir...

X Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description An app that sends navigation failures to an error page the documented way never finishes the redir...

Opengraph URL: https://github.com/angular/angular/issues/71126

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Angular Router state committed before activation can make a valid error-handler redirect loop forever","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nrouter\n\n### Is this a regression?\n\nNo\n\n### Description\n\nAn app that sends navigation failures to an error page the documented way never finishes the redirect:\n\n```ts\nwithNavigationErrorHandler(() => new RedirectCommand(inject(Router).parseUrl('/error')));\n```\n\n`/error` renders fine on its own. But `GET /(//)` makes the SSR worker stop answering everything, while it spins the event loop.\n\nIt comes down to an ordering problem. `commitTransition()` runs on `BeforeActivateRoutes`, before the browser URL is written:\n\n```ts\nelse if (e instanceof BeforeActivateRoutes) {\n  this.commitTransition(currentTransition);\n  if (this.urlUpdateStrategy === 'deferred' && !currentTransition.extras.skipLocationChange) {\n    this.setBrowserUrl(this.createBrowserPath(currentTransition), currentTransition);\n  }\n}\n```\n\n`ActivatedRoute.snapshot` is only assigned later, by `advanceActivatedRoute()` during activation. So a throw in between leaves a committed `routerState` whose routes have no snapshot.\n\nNormally that gets repaired, because `NavigationError` calls `restoreHistory(t, true)`. A `RedirectCommand` takes the other branch instead, and that branch is excluded:\n\n```ts\nelse if (e instanceof NavigationCancel && !isRedirectingEvent(e)) {\n  this.restoreHistory(currentTransition);\n}\n```\n\nSo the redirect runs with the half-committed state as its previous state, and `DefaultRouteReuseStrategy` reads it unguarded:\n\n```ts\nshouldReuseRoute(future, curr) {\n  return future.routeConfig === curr.routeConfig;   // curr is undefined\n}\n```\n\nThat throws, the handler answers with another `RedirectCommand`, and it never ends.\n\nThe URL is not the only way into that window. `ActivateRoutes.activate()` advances one route at a time, and the component is created in between:\n\n```ts\nactivateRoutes(futureNode, currNode, parentContexts) {\n  advanceActivatedRoute(future);                 // this route gets its snapshot\n  // ...then context.outlet.activateWith() creates the component, and that is what throws\n}\n```\n\nWith one outlet the route is already advanced when the component throws, so nothing is left behind. With two, the primary advances, its component throws, and the sibling outlet never advances. Same half-committed state, no odd URL involved.\n\n### Minimal Reproduction\n\n```ts\n@Component({selector: 'app-login', template: '\u003cp>LOGIN-OK\u003c/p>'})\nexport class Login {\n  // guards pass returnUrl around encoded, so it gets decoded again here\n  protected readonly returnUrl = decodeURIComponent(\n    inject(ActivatedRoute).snapshot.queryParamMap.get('returnUrl') ?? '/',\n  );\n}\n\nexport const routes: Routes = [\n  { path: 'shell', component: Shell },\n  { path: 'error', component: ErrorPage },\n  // control: an ordinary resolver failure, no commit-window throw\n  {\n    path: 'boom',\n    component: Shell,\n    resolve: {\n      x: () => {\n        throw new Error('nope');\n      },\n    },\n  },\n  { path: 'login', component: Login },\n  { path: 'room/:id', outlet: 'chat', component: Chat },\n  { path: '**', component: Shell },\n];\n```\n\n`\u003crouter-outlet />\u003crouter-outlet name=\"chat\" />` in the shell, `\u003cbase href=\"/\">` and `urlUpdateStrategy: 'deferred'` left at their defaults.\n\nCase A, the browser URL write fails:\n\n```text\nlocalhost:4000/boom         # 302, recovers in one hop\nlocalhost:4000/(//)         # Never answers, spins the event loop\n```\n\n`/boom` is the control: it hits the same handler and the same `/error`, and recovers in one hop. `/(//)` never answers.\n\nCase B, a component fails next to a named outlet. `?returnUrl=%25` is a correctly encoded `%`, so the URL itself is valid. The Router hands the component a decoded value already, so `decodeURIComponent` gets `%` and throws `URIError: URI malformed`:\n\n```text\nlocalhost:4000/login?returnUrl=%25                    # 302, throws and recovers in one hop\nlocalhost:4000/login(chat:room/42)?returnUrl=%25      # Never answers\n```\n\nThe first line is the control. Same throw, one hop, worker fine. The only difference on the second is `(chat:room/42)`, and that comes from the request, not from the configuration.\n\nThe error chain, written synchronously because nothing async flushes once the loop starts:\n\n```text\nERRCHAIN #1 nope                                                   \u003c- /boom, stops here\nERRCHAIN #2 NG05701: //                                            \u003c- /(//)\nERRCHAIN #3 Cannot read properties of undefined (reading 'routeConfig')\nERRCHAIN #4 Cannot read properties of undefined (reading 'routeConfig')\n...\n```\n\nCase B produces the same chain, with `URI malformed` in place of `NG05701`.\n\n### Please provide a link to a minimal reproduction of the bug\n\nSee https://github.com/SkyZeroZx/angular-ssr-router-redirect-loop\n\n### Anything else?\n\n\nI narrowed this down to `RedirectCommand`. With the same setup, no handler or a handler returning `undefined` gives a normal 404, and `router.navigate('/error')` is noisy but settles. Only returning a `RedirectCommand` never completes, through either `withNavigationErrorHandler()` or `RouterModule.forRoot({errorHandler})`.\n\nThe setup is otherwise default. Case A needs the `**` route, because without it `/(//)` fails before the router commits anything. Case B needs the named outlet in the shell template instead, and the unactivated route has to be a sibling rather than a descendant.\n\n#71094 fixes the `/(//)` trigger by preventing `DefaultUrlSerializer` from producing protocol relative paths (reported at #69700), but it only removes one way into the window above. \n\nCase B still reproduces with it applied. A try/catch around `setBrowserUrl()` has the same gap: it handles one source of the throw, but the state may already be committed.\n\nWhat covers both is restoring the internal state when a redirecting navigation is canceled, but only when that transition actually committed (`this.routerState === targetRouterState`). \n\nThe browser URL does not need restoring, since the redirect replaces it. Adding `curr?.routeConfig` in `shouldReuseRoute()` stops the crash but leaves the state inconsistent.\n","author":{"url":"https://github.com/SkyZeroZx","@type":"Person","name":"SkyZeroZx"},"datePublished":"2026-10-01T19:01:27Z","url":"https://github.com/angular/angular/issues/71126"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:10bd4264-6a06-19fc-04ff-4d1fee5b1549
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA50A:1558B:3B0B2F:53FE36:6AFDE46B
html-safe-nonce4b69f4ab73c1f0ff68aa774deb3c6ff79f1d4509ef5c09c8e3e72409257b2115
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTBBOjE1NThCOjNCMEIyRjo1M0ZFMzY6NkFGREU0NkIiLCJ2aXNpdG9yX2lkIjoiNjQzMDUzNjEwOTUxNTQ2NTgzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2848799a67202b046b3d5c2f91f16b407a02e46d9820eb0fb00d6ef797737215
hovercard-subject-tagissue:5667561426
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/71126/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9a912dbba3f610ee6daad95e8f28bb98608482b77ab91d4316089cf92bd8ddc0/angular/angular/issues/71126
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9a912dbba3f610ee6daad95e8f28bb98608482b77ab91d4316089cf92bd8ddc0/angular/angular/issues/71126
og:image:altWhich @angular/* package(s) are the source of the bug? router Is this a regression? No Description An app that sends navigation failures to an error page the documented way never finishes the redir...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameSkyZeroZx
hostnamegithub.com
expected-hostnamegithub.com
None91ef1a291a064ac31ac459ab3f75261dbdd924c41ea5bd027e591c5b46cc9ce7
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released62bc98ce2346f4006e4a2810e9e22f37e7e6422
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/71126#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F71126
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F71126
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/71126
Reloadhttps://github.com/angular/angular/issues/71126
Reloadhttps://github.com/angular/angular/issues/71126
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues833 (833)https://github.com/angular/angular/issues
Pull requests127 (127)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/71126
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/71126
#71130https://github.com/angular/angular/pull/71130
Angular Router state committed before activation can make a valid error-handler redirect loop foreverhttps://github.com/angular/angular/issues/71126#top
#71130https://github.com/angular/angular/pull/71130
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
needsTriagehttps://github.com/angular/angular/milestone/83
https://github.com/SkyZeroZx
SkyZeroZxhttps://github.com/SkyZeroZx
on Oct 1, 2026https://github.com/angular/angular/issues/71126#issue-5667561426
https://github.com/SkyZeroZx/angular-ssr-router-redirect-loophttps://github.com/SkyZeroZx/angular-ssr-router-redirect-loop
#71094https://github.com/angular/angular/pull/71094
#69700https://github.com/angular/angular/issues/69700
angular-robothttps://github.com/apps/angular-robot
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
gemini-triagedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
on Oct 1, 2026https://github.com/angular/angular/issues/71126#event-32280431769
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on Oct 1, 2026https://github.com/angular/angular/issues/71126#event-32280434321
SkyZeroZxhttps://github.com/SkyZeroZx
on Oct 1, 2026https://github.com/angular/angular/issues/71126#event-32281008138
fix(router): ignore routes that a failed navigation never activatedhttps://github.com/SkyZeroZx/angular/commit/d385ebfd28dc50bc6e6caa3d3e95d2d0c7a4c3f9
https://docs.github.com/articles/closing-issues-via-commit-messages
d385ebfhttps://github.com/SkyZeroZx/angular/commit/d385ebfd28dc50bc6e6caa3d3e95d2d0c7a4c3f9
atscotthttps://github.com/atscott
on Oct 1, 2026https://github.com/angular/angular/issues/71126#event-32283465112
fix(router): reset internal state on error handler redirect after sta…https://github.com/atscott/angular/commit/5009842fbd084f872d0d1c5f5623d6e1f36b1f2c
https://docs.github.com/articles/closing-issues-via-commit-messages
5009842https://github.com/atscott/angular/commit/5009842fbd084f872d0d1c5f5623d6e1f36b1f2c
https://github.com/atscott
atscotthttps://github.com/atscott
on Oct 1, 2026https://github.com/angular/angular/issues/71126#issuecomment-5939321181
#71130https://github.com/angular/angular/pull/71130
atscotthttps://github.com/atscott
on Oct 1, 2026https://github.com/angular/angular/issues/71126#event-32283919425
fix(router): reset internal state on error handler redirect after sta…https://github.com/atscott/angular/commit/2c0694f8ecd4190b9420a0eba2b7b741bd175598
https://docs.github.com/articles/closing-issues-via-commit-messages
2c0694fhttps://github.com/atscott/angular/commit/2c0694f8ecd4190b9420a0eba2b7b741bd175598
fix(router): reset internal state on error handler redirect after sta…https://github.com/atscott/angular/commit/edd00affa27aa6beb56454052bda69848b5e13e3
https://docs.github.com/articles/closing-issues-via-commit-messages
edd00afhttps://github.com/atscott/angular/commit/edd00affa27aa6beb56454052bda69848b5e13e3
fix(router): reset internal state on error handler redirect after sta…https://github.com/atscott/angular/commit/654828d98e57030e024c9e9374bec2dc479359e6
https://docs.github.com/articles/closing-issues-via-commit-messages
654828dhttps://github.com/atscott/angular/commit/654828d98e57030e024c9e9374bec2dc479359e6
https://github.com/SkyZeroZx
SkyZeroZxhttps://github.com/SkyZeroZx
on Oct 1, 2026https://github.com/angular/angular/issues/71126#issuecomment-5941749099
#71130https://github.com/angular/angular/pull/71130
#71094https://github.com/angular/angular/pull/71094
withNavigationErrorHandlerhttps://angular.dev/api/router/withNavigationErrorHandler
RedirectCommandhttps://angular.dev/api/router/RedirectCommand
UrlTreehttps://angular.dev/api/router/UrlTree
RedirectCommandhttps://angular.dev/api/router/RedirectCommand
Routerhttps://angular.dev/api/router/Router
NavigationErrorhttps://angular.dev/api/router/NavigationError
NavigationCancelhttps://angular.dev/api/router/NavigationCancel
RedirectCommandhttps://angular.dev/api/router/RedirectCommand
Routerhttps://angular.dev/api/router/Router
https://github.com/atscott
atscotthttps://github.com/atscott
on Oct 1, 2026https://github.com/angular/angular/issues/71126#issuecomment-5941974498
fix(router): fall back when serializing protocol-relative URLs #71094https://github.com/angular/angular/pull/71094
fix(router): reset internal state on error handler redirect after state commit #71130https://github.com/angular/angular/pull/71130
kirjshttps://github.com/kirjs
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#71130https://github.com/angular/angular/pull/71130
on Oct 2, 2026https://github.com/angular/angular/issues/71126#event-32358133009
kirjshttps://github.com/kirjs
on Oct 2, 2026https://github.com/angular/angular/issues/71126#event-32358135833
fix(router): reset internal state on error handler redirect after sta…https://github.com/angular/angular/commit/fc91c725a0fcc9e3370f518199271773b8c1a093
https://docs.github.com/articles/closing-issues-via-commit-messages
fc91c72https://github.com/angular/angular/commit/fc91c725a0fcc9e3370f518199271773b8c1a093
angular-robothttps://github.com/angular-robot
on Oct 2, 2026https://github.com/angular/angular/issues/71126#event-32358217115
fix(router): reset internal state on error handler redirect after sta…https://github.com/angular-robot/angular/commit/f591d36fa7acf519d0b2cc53879dce17dd691895
https://docs.github.com/articles/closing-issues-via-commit-messages
f591d36https://github.com/angular-robot/angular/commit/f591d36fa7acf519d0b2cc53879dce17dd691895
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Nov 2, 2026https://github.com/angular/angular/issues/71126#issuecomment-6565983077
automatic conversation locking policyhttps://github.com/angular/angular/blob/f0fbced1c55bc8b8ed9df01cea99df42f3e7eae3/contributing-docs/auto-issue-locking.md
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Nov 2, 2026https://github.com/angular/angular/issues/71126#event-34862491721
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/71126
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/71126
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
needsTriageNo due datehttps://github.com/angular/angular/milestone/83
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.