Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router): Avoid unhandled promise rejections of navigations by def… #57350

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Aug 12, 2024

…ault

This is the most sane thing to do given that
applications very rarely handle the promise rejection and, as a result, would get "unhandled promise rejection" console logs. The vast majority of applications would not be affected by this change so omitting a migration seems reasonable. Instead, applications that rely on rejection can specifically opt-in to the old behavior.

BREAKING CHANGE: Navigation promises will no longer be rejected when a navigation error occurs. The error is still reported to the error handler and the events as a NavigationError but the promise will instead resolve to false as with any other failed navigation. This resolves issues that come from unhandled promise rejections, as the navigation promise is rarely used and likely unhandled if it is rejected. Tests or production code that rely on the rejection can opt back in by using setting resolveNavigationPromiseOnError to false in RouterModule.forRoot or withRouterConfig of provideRouter.

…ault

This is the most sane thing to do given that
applications very rarely handle the promise rejection and, as a
result, would get "unhandled promise rejection" console logs.
The vast majority of applications would not be affected by this
change so omitting a migration seems reasonable. Instead,
applications that rely on rejection can specifically opt-in to the
old behavior.

BREAKING CHANGE: Navigation promises will no longer be rejected when a
navigation error occurs. The error is still reported to the error
handler and the events as a `NavigationError` but the promise will
instead resolve to `false` as with any other failed navigation. This
resolves issues that come from unhandled promise rejections, as the
navigation promise is rarely used and likely unhandled if it is
rejected. Tests or production code that rely on the rejection can opt
back in by using setting `resolveNavigationPromiseOnError` to `false` in
`RouterModule.forRoot` or `withRouterConfig` of `provideRouter`.
@atscott atscott added breaking changes area: router target: major This PR is targeted for the next major release labels Aug 12, 2024
@ngbot ngbot bot added this to the Backlog milestone Aug 12, 2024
@angular-robot angular-robot bot added the detected: breaking change PR contains a commit with a breaking change label Aug 12, 2024
@atscott atscott requested a review from AndrewKushnir August 12, 2024 16:52
@atscott atscott added the action: global presubmit The PR is in need of a google3 global presubmit label Aug 12, 2024
@atscott
Copy link
Contributor Author

atscott commented Aug 12, 2024

// cc @alan-agius4 since this came up in the past

Copy link
Contributor

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

LGTM

@atscott
Copy link
Contributor Author

atscott commented Aug 13, 2024

Adding blocked label, converting back to draft. There are ~300 failures in TGP and I won't have time to fix these before v19.

@atscott atscott marked this pull request as draft August 13, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: global presubmit The PR is in need of a google3 global presubmit area: router breaking changes detected: breaking change PR contains a commit with a breaking change state: blocked target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants