Title: Router error boundaries: a reused RedirectCommand instance only redirects the first time · Issue #72027 · angular/angular · GitHub
Open Graph Title: Router error boundaries: a reused RedirectCommand instance only redirects the first time · Issue #72027 · angular/angular
X Title: Router error boundaries: a reused RedirectCommand instance only redirects the first time · Issue #72027 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No (new in 22.3.0-rc.0: route error boundaries) Description With withErrorBoundaries(), throwing a RedirectCommand from a routed component is supposed to...
Open Graph Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No (new in 22.3.0-rc.0: route error boundaries) Description With withErrorBoundaries(), throwing a RedirectComman...
X Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No (new in 22.3.0-rc.0: route error boundaries) Description With withErrorBoundaries(), throwing a RedirectComman...
Opengraph URL: https://github.com/angular/angular/issues/72027
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Router error boundaries: a reused RedirectCommand instance only redirects the first time","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nrouter\n\n### Is this a regression?\n\nNo (new in 22.3.0-rc.0: route error boundaries)\n\n### Description\n\nWith `withErrorBoundaries()`, throwing a `RedirectCommand` from a routed component is supposed to always navigate (see `packages/router/docs/error_boundaries.md`, \"The Rule: `RedirectCommand` Always Navigates\").\n\nTo avoid dispatching the same redirect several times while it bubbles through nested outlets, `triggerRedirectIfCommand` in `router_error_boundary.ts` tags the `RedirectCommand` object itself with a `REDIRECT_DISPATCHED` symbol and skips the navigation if the tag is already set. The tag is never cleared, so if the same `RedirectCommand` **instance** is thrown again later (a module-level constant, a field on a service, a cached value), the router no longer navigates. The user stays on the failing route with the error component rendered.\n\n### Minimal reproduction\n\n```ts\nconst toLogin = new RedirectCommand(router.parseUrl('/login')); // created once and reused\n\n@Component({template: 'A'})\nclass Guarded {\n constructor() {\n throw toLogin;\n }\n}\n\nprovideRouter(\n [\n {path: '', component: Home},\n {path: 'a', component: Guarded},\n {path: 'login', component: Login},\n ],\n withErrorBoundaries({defaultErrorComponent: ErrorCmp}),\n);\n\nawait router.navigateByUrl('/a'); // -> /login (correct)\nawait router.navigateByUrl('/');\nawait router.navigateByUrl('/a'); // expected /login, but the router stays on /a and renders ErrorCmp\n```\n\nConfirmed on `@angular/router@22.3.0-rc.0`. The relevant code on `main` has not changed since the feature landed.\n\n### Expected\n\nEvery time a `RedirectCommand` is thrown from a routed component the router navigates, regardless of whether the instance was thrown before. De-duplication should only apply to the same occurrence bubbling through several outlets.\n\n### Notes / possible directions\n\n- Workaround: always throw a new `RedirectCommand`.\n- The de-duplication could be scoped to one bubbling pass instead of the lifetime of the instance, for example by clearing the mark in a microtask after it is set, or by tracking dispatched commands in a `WeakSet` that is reset when the navigation that rendered the failing outlet ends.\n- Writing a symbol property onto a user-supplied object also throws in strict mode if that object is frozen; a `WeakSet` would avoid that as well.\n\nHappy to send a PR if the direction is agreed.\n\n### Angular version\n\n22.3.0-rc.0 and `main`\n","author":{"url":"https://github.com/mojerf","@type":"Person","name":"mojerf"},"datePublished":"2026-11-13T12:25:16Z","url":"https://github.com/angular/angular/issues/72027"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ff3b7717-d564-e268-9abc-e861ddc40177 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D25E:31D532:F82748:149DA0E:6B01DBAD |
| html-safe-nonce | 53904552f70c2bb8431752d9212934334b9f5fa9d553bcb115edcb4259b94cb0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjVFOjMxRDUzMjpGODI3NDg6MTQ5REEwRTo2QjAxREJBRCIsInZpc2l0b3JfaWQiOiI3MzUxNzg5MTA1NDAwODk2NDI5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ebc792bed7e712e1cf698cc8cff5ae5e27458fe054ec896ad3e20da20ec6090f |
| hovercard-subject-tag | issue:6371196437 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/72027/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4f92c9d60c40a46b43e1e2054ea775705b478611967fb7618b8558838c151386/angular/angular/issues/72027 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4f92c9d60c40a46b43e1e2054ea775705b478611967fb7618b8558838c151386/angular/angular/issues/72027 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? router Is this a regression? No (new in 22.3.0-rc.0: route error boundaries) Description With withErrorBoundaries(), throwing a RedirectComman... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mojerf |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width