René's URL Explorer Experiment


Title: Add option to not reset Url and Router state to Angular Router on Navigation Errors · Issue #42915 · angular/angular · GitHub

Open Graph Title: Add option to not reset Url and Router state to Angular Router on Navigation Errors · Issue #42915 · angular/angular

X Title: Add option to not reset Url and Router state to Angular Router on Navigation Errors · Issue #42915 · angular/angular

Description: Which @angular/* package(s) are relevant/releated to the feature request? router Description Currently the Angular router resets the state and the url on navigation errors [1] and on Navigation cancels that do not redirect [2]. Due to th...

Open Graph Description: Which @angular/* package(s) are relevant/releated to the feature request? router Description Currently the Angular router resets the state and the url on navigation errors [1] and on Navigation can...

X Description: Which @angular/* package(s) are relevant/releated to the feature request? router Description Currently the Angular router resets the state and the url on navigation errors [1] and on Navigation can...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add option to not reset Url and Router state to Angular Router on Navigation Errors","articleBody":"### Which @angular/* package(s) are relevant/releated to the feature request?\r\n\r\nrouter\r\n\r\n### Description\r\n\r\nCurrently the Angular router resets the state and the url on navigation errors [1] and on Navigation cancels that do not redirect [2]. Due to this, if someone is navigating from “a” -> “b” and hits a navigation error or a failed canActivate guard, the url stays on “a”. Furthermore, if the url update strategy is ‘eager’, the url actually gets changed from ‘a’ to ‘b’ prior to the error and is then changed back to ‘a’, resulting in the url flickering for the user from the destination url back to their origin url. \r\n\r\nThis makes it difficult to show an error page while maintaining the context of the destination url “b”, and is somewhat counterintuitive when using the url update strategy of ‘eager’ as the url changes back and forth. See https://github.com/angular/angular/issues/17004 for a similar feature request that focuses on showing an error page on pages that have failed canActivate guards.\r\n\r\n[1] https://github.com/angular/angular/blob/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959/packages/router/src/router.ts#L955\r\n[2] https://github.com/angular/angular/blob/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959/packages/router/src/router.ts#L923\r\n\r\n\r\n### Proposed solution\r\n\r\nAdd a new setting in ExtraOptions[1] named resetUrlOnError that is by default true.\r\n```\r\nexport interface ExtraOptions{\r\n...\r\nresetUrlOnError?: boolean;\r\n}\r\n```\r\nAnd then where `resetStateAndUrl` is called, we reference this option to conditionally skip calling it if that setting is disabled.\r\n```\r\nif(this.resetUrlOnError){\r\n\tthis.resetStateAndUrl(t.currentRouterState, t.currentUrlTree, t.rawUrl);\r\n}\r\n```\r\n\r\nHowever, this only results in the behaviour we want when the url update strategy is set to eager, as the url is updated prior to when the navigation error is encountered. Due to this, we will also only skip this call if the url update strategy is set to eager. We would also make sure to call out in a comment for `resetUrlOnError` that it only works in eager mode.\r\n\r\n```\r\nif(this.resetUrlOnError || this.urlUpdateStrategy !== ‘eager’){\r\n\tthis.resetStateAndUrl(t.currentRouterState, t.currentUrlTree, t.rawUrl);\r\n}\r\n```\r\n\r\n[1] https://github.com/angular/angular/blob/1d9d02696eadbee2c2f719e432efca22f1e494e9/packages/router/src/router_module.ts#L256\r\n\r\n\r\n\r\n### Alternatives considered\r\n\r\nAlong with the above change, we could modify the state and url for navigation errors that are encountered when the url update strategy is set to deferred. However as we do not know where in the navigation the error occurred, and therefore we do not know what state the url and router state will be in, it seems safer to only support this setting with the url update strategy set to eager. This also makes more sense with the eager url update strategy as we are specifically choosing to not wait until after the navigation ends to change the url.\r\n\r\nAnother alternative would be to move the resetStateAndUrl call into the default ErrorHandler [1], which would allow users to overwrite this and define their own error handling in that handler. However this function is currently empty and is often overwritten, so moving this call into this function would require a careful migration process to ensure no angular users are broken by the change.\r\n\r\nhttps://github.com/angular/angular/issues/27148 would also enable us to achieve this by giving us more options to set during failed guards. However, those settings would need to be set for every guard and as it is focused on guards, it would not solve the more general case of errors encountered during a navigation.\r\n\r\nOn top of all this, this proposed change is fairly simple and straightforward, which results in no change in behavior by default. Each of the above alternatives add complexity which would require more investigation to ensure that no existing users of Angular are broken by a change to the Router code.\r\n\r\n[1] https://github.com/angular/angular/blob/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959/packages/router/src/router.ts#L223\r\n","author":{"url":"https://github.com/DiegoRGonzalez","@type":"Person","name":"DiegoRGonzalez"},"datePublished":"2021-07-21T21:50:08Z","url":"https://github.com/angular/angular/issues/42915"}

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:dc8843a5-20b8-4770-e1c8-157878c2368e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB236:3C21B:C44990:FE1D72:6B00EE70
html-safe-noncebdf375f77b461090b936152aac5f5000aabf5e26605dbc259d085252eba7a95e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjM2OjNDMjFCOkM0NDk5MDpGRTFENzI6NkIwMEVFNzAiLCJ2aXNpdG9yX2lkIjoiNzAzODc3NzExNTg0MzU1NDkyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacf9ec57a18b1b522f67f0f184a7c67705bc7c703c8ec9f12fbad450262a3c8cd4
hovercard-subject-tagissue:950136909
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/42915/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c88bb4b81b329690fe3e3847a2c3777823c4b332b546a3e1efc6e952e30550af/angular/angular/issues/42915
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c88bb4b81b329690fe3e3847a2c3777823c4b332b546a3e1efc6e952e30550af/angular/angular/issues/42915
og:image:altWhich @angular/* package(s) are relevant/releated to the feature request? router Description Currently the Angular router resets the state and the url on navigation errors [1] and on Navigation can...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameDiegoRGonzalez
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
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
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/42915#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F42915
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%2F42915
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/42915
Reloadhttps://github.com/angular/angular/issues/42915
Reloadhttps://github.com/angular/angular/issues/42915
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests140 (140)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/42915
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/42915
Add option to not reset Url and Router state to Angular Router on Navigation Errorshttps://github.com/angular/angular/issues/42915#top
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
hotlist: googlehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22hotlist%3A%20google%22
router: navigation pipeevents/scheduleNavigation/transitions observablehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22router%3A%20navigation%20pipe%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/DiegoRGonzalez
DiegoRGonzalezhttps://github.com/DiegoRGonzalez
on Jul 21, 2021https://github.com/angular/angular/issues/42915#issue-950136909
#17004https://github.com/angular/angular/issues/17004
angular/packages/router/src/router.tshttps://github.com/angular/angular/blob/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959/packages/router/src/router.ts#L955
e2aa765https://github.com/angular/angular/commit/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959
angular/packages/router/src/router.tshttps://github.com/angular/angular/blob/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959/packages/router/src/router.ts#L923
e2aa765https://github.com/angular/angular/commit/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959
angular/packages/router/src/router_module.tshttps://github.com/angular/angular/blob/1d9d02696eadbee2c2f719e432efca22f1e494e9/packages/router/src/router_module.ts#L256
1d9d026https://github.com/angular/angular/commit/1d9d02696eadbee2c2f719e432efca22f1e494e9
#27148https://github.com/angular/angular/issues/27148
angular/packages/router/src/router.tshttps://github.com/angular/angular/blob/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959/packages/router/src/router.ts#L223
e2aa765https://github.com/angular/angular/commit/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959
atscotthttps://github.com/atscott
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
hotlist: googlehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22hotlist%3A%20google%22
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
on Jul 21, 2021https://github.com/angular/angular/issues/42915#event-5052721857
ngbothttps://github.com/apps/ngbot
Backloghttps://github.com/angular/angular/milestone/82
on Jul 21, 2021https://github.com/angular/angular/issues/42915#event-5052722091
atscotthttps://github.com/atscott
router: navigation pipeevents/scheduleNavigation/transitions observablehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22router%3A%20navigation%20pipe%22
on Jul 21, 2021https://github.com/angular/angular/issues/42915#event-5052722234
https://github.com/Airblader
Airbladerhttps://github.com/Airblader
on Jul 22, 2021https://github.com/angular/angular/issues/42915#issuecomment-884651296
#27148https://github.com/angular/angular/issues/27148
#27148https://github.com/angular/angular/issues/27148
#27148https://github.com/angular/angular/issues/27148
angular-robothttps://github.com/apps/angular-robot
votes requiredhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22votes%20required%22
on Jul 22, 2021https://github.com/angular/angular/issues/42915#event-5055912110
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on Jul 22, 2021https://github.com/angular/angular/issues/42915#issuecomment-884941316
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
https://github.com/DiegoRGonzalez
DiegoRGonzalezhttps://github.com/DiegoRGonzalez
on Jul 22, 2021https://github.com/angular/angular/issues/42915#issuecomment-885125414
#27148https://github.com/angular/angular/issues/27148
#27148https://github.com/angular/angular/issues/27148
#27148https://github.com/angular/angular/issues/27148
https://github.com/Airblader
Airbladerhttps://github.com/Airblader
on Jul 22, 2021https://github.com/angular/angular/issues/42915#issuecomment-885138839
#27148https://github.com/angular/angular/issues/27148
https://github.com/DiegoRGonzalez
DiegoRGonzalezhttps://github.com/DiegoRGonzalez
on Jul 22, 2021https://github.com/angular/angular/issues/42915#issuecomment-885152668
#27148https://github.com/angular/angular/issues/27148
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on Aug 30, 2021https://github.com/angular/angular/issues/42915#issuecomment-908372984
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on Sep 19, 2021https://github.com/angular/angular/issues/42915#issuecomment-922478899
communityhttps://angular.io/resources?category=community
packagehttps://angular.io/guide/creating-libraries
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
angular-robothttps://github.com/apps/angular-robot
insufficient voteshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22insufficient%20votes%22
votes requiredhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22votes%20required%22
on Sep 19, 2021https://github.com/angular/angular/issues/42915#event-5324720977
https://github.com/atscott
atscotthttps://github.com/atscott
on Dec 16, 2021https://github.com/angular/angular/issues/42915#issuecomment-996117252
atscotthttps://github.com/atscott
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Dec 16, 2021https://github.com/angular/angular/issues/42915#event-5780572878
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Jan 16, 2022https://github.com/angular/angular/issues/42915#issuecomment-1013903235
automatic conversation locking policyhttps://github.com/angular/angular/blob/8f24bc9443b3872fe095d9f7f77b308a361a13b4/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Jan 16, 2022https://github.com/angular/angular/issues/42915#event-5900488056
alxhubhttps://github.com/alxhub
on Apr 17, 2024https://github.com/angular/angular/issues/42915#event-12515475372
feat(router): `withNavigationErrorHandler` can convert errors to redi…https://github.com/angular/angular/commit/4a42961393b3abf40f34374df059d3959dadecc0
https://docs.github.com/articles/closing-issues-via-commit-messages
4a42961https://github.com/angular/angular/commit/4a42961393b3abf40f34374df059d3959dadecc0
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/42915
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/42915
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
hotlist: googlehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22hotlist%3A%20google%22
router: navigation pipeevents/scheduleNavigation/transitions observablehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22router%3A%20navigation%20pipe%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
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.