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): handle unhandled promise rejections with ErrorHandler #51042

Closed
wants to merge 1 commit into from

Conversation

dzinxed
Copy link

@dzinxed dzinxed commented Jul 14, 2023

Pass errors from calls that returned promises to ErrorHandler. These calls returned promises that could fail but were neither caught nor propagated. This caused "Unhandled (in promise)" errors on the console.

I'll be happy to add some unit test but I want to validate the approach first. Is it OK to inject ErrorHandlers in these two places?

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

If a resolver rejects, "Unhandled (in promise)" errors are shown in the console (aside from the standard Angular navigation error handling). This is because there are calls to methods that return promises, but the results of these promises are never checked.

Issue Number: N/A

What is the new behavior?

Promise rejections are caught and sent to ErrorHandler.handleError.

Does this PR introduce a breaking change?

  • Yes
  • No

Pass errors from calls that returned promises to ErrorHandler. These calls returned promises that could fail but were neither caught nor propagated. This caused "Unhandled (in promise)" errors on the console.
@pullapprove pullapprove bot requested a review from AndrewKushnir July 14, 2023 14:30
@ngbot ngbot bot added this to the Backlog milestone Jul 14, 2023
@pullapprove pullapprove bot removed the request for review from atscott August 5, 2023 21:00
@atscott
Copy link
Contributor

atscott commented Aug 14, 2023

I'll be happy to add some unit test but I want to validate the approach first.

Sounds good.

Is it OK to inject ErrorHandlers in these two places?

Should be. We'll run global presubmit to double check.

@atscott atscott added the action: global presubmit The PR is in need of a google3 global presubmit label Aug 14, 2023
@atscott
Copy link
Contributor

atscott commented Aug 25, 2023

Is it OK to inject ErrorHandlers in these two places?

It looks like this would be a breaking change based on the presubmits. Some ErrorHandler implementations inject the Router in order to perform navigations to error pages. If we want to use the ErrorHandler in the Router, it'll have to be changed to injector.get instead.

@atscott atscott added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: global presubmit The PR is in need of a google3 global presubmit labels Aug 25, 2023
@atscott
Copy link
Contributor

atscott commented Aug 30, 2023

Note that this would also be superseded by #48910

@atscott
Copy link
Contributor

atscott commented Nov 30, 2023

Closing in favor of #48910

@atscott atscott closed this Nov 30, 2023
@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 Dec 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews area: router
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants