Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(router): Prevent dangling promise rejections from internal naviga… #60162

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

Closed
wants to merge 1 commit into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Feb 28, 2025

…tions

Though the plan is to change the default behavior or the router to instead resolve the navigation promise with false to match all other failed navigations, we should still prevent dangling promise rejections from navigations triggered internally when developers opt to use the old (current) behavior.

@atscott atscott added area: router target: patch This PR is targeted for the next patch release labels Feb 28, 2025
@atscott atscott requested a review from alan-agius4 February 28, 2025 20:14
@ngbot ngbot bot added this to the Backlog milestone Feb 28, 2025
@atscott atscott added target: major This PR is targeted for the next major release requires: TGP This PR requires a passing TGP before merging is allowed and removed target: patch This PR is targeted for the next patch release labels Feb 28, 2025
@pullapprove pullapprove bot removed the requires: TGP This PR requires a passing TGP before merging is allowed label Feb 28, 2025
@atscott
Copy link
Contributor Author

atscott commented Feb 28, 2025

Moving to target major. Unsurprisingly this causes tests to fail that are mocking the router. This will not be considered a breaking change but still might as well move it to major to avoid breaking tests in patch. That said though, TGP will determine whether this is even able to land as-is. Potentially, this will need to have ?.catch to avoid when stubs are returning undefined from the navigation.

@atscott atscott added the requires: TGP This PR requires a passing TGP before merging is allowed label Feb 28, 2025
@pullapprove pullapprove bot removed the requires: TGP This PR requires a passing TGP before merging is allowed label Feb 28, 2025
@atscott
Copy link
Contributor Author

atscott commented Mar 3, 2025

Adding blocked, as this change will require further discussion. Developers using ZoneJS indirectly rely on the rejection to report to ErrorHandler. By adding the catch, errors will no longer be reported by default which is undesirable. These catch blocks could report directly to the error handler but would mean duplicate reports if we also make a change to the navigation pipeline to also directly report to error handler in order to ensure it's still done when resolveNavigationPromiseOnError is set to true.

@atscott atscott force-pushed the catchinitialnavrejection branch from 0e8ebf5 to 3acf97a Compare March 3, 2025 22:08
@atscott atscott added requires: TGP This PR requires a passing TGP before merging is allowed and removed state: blocked labels Mar 3, 2025
@pullapprove pullapprove bot removed the requires: TGP This PR requires a passing TGP before merging is allowed label Mar 3, 2025
…tions

Though the plan is to change the default behavior or the router to
instead resolve the navigation promise with `false` to match all other
failed navigations, we should still prevent dangling promise rejections
from navigations triggered internally when developers opt to use the old
(current) behavior.
@atscott atscott force-pushed the catchinitialnavrejection branch from 3acf97a to b90ba51 Compare March 4, 2025 18:03
@atscott
Copy link
Contributor Author

atscott commented Mar 6, 2025

caretaker note: This change now has a green TGP after ~5 fixes to tests in g3. A few were spying on navigateByUrl and not returning a promise. Two others were somehow getting the promise rejection swallowed by ZoneJS. I would not consider either of these to be noteworthy as a breaking change

@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Mar 6, 2025
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 219f41d.

The changes were merged into the following branches: main

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: router target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants