fix(core): avoid injecting internal error handler from a destroyed injector#62275
Closed
arturovt wants to merge 1 commit intoangular:mainfrom
Closed
fix(core): avoid injecting internal error handler from a destroyed injector#62275arturovt wants to merge 1 commit intoangular:mainfrom
arturovt wants to merge 1 commit intoangular:mainfrom
Conversation
arturovt
commented
Jun 25, 2025
13c53f1 to
4c49e1f
Compare
atscott
reviewed
Jul 9, 2025
| // Should we wrap it in a try-catch and re-throw in a timer? | ||
| // Or there's any other precise solution? | ||
| try { | ||
| const errorHandler = injector.get(INTERNAL_APPLICATION_ERROR_HANDLER, null); |
Contributor
There was a problem hiding this comment.
try...catch should only be around the inject call. The errorHandler itself can still throw an error that we don't want to throw in a timeout
005ace0 to
b140e94
Compare
Contributor
Author
|
@atscott any more changes required for this change? |
atscott
approved these changes
Aug 26, 2025
Contributor
|
Presubmit is "green". |
…jector
This commit prevents lazy injection of the internal `ErrorHandler` from a destroyed injector, which would otherwise result in a secondary "destroyed injector" error.
The `handleUncaughtError` function is used in a wrapped event listener that invokes the `ErrorHandler` if the listener throws. A simple case in a micro-frontend application:
```ts
onNavigationToAnotherApp() {
this.appRef.destroy();
do_some_stuff_ie_loggin_that_may_throw();
}
```
If the function throws an error, Angular attempts to inject the `ErrorHandler` from a destroyed injector.
b140e94 to
6d0d168
Compare
Contributor
|
JFYI, pushed a rebase to this branch to rerun the CI (it didn't start previously for some reasons). |
Contributor
AndrewKushnir
pushed a commit
that referenced
this pull request
Aug 27, 2025
…jector (#62275) This commit prevents lazy injection of the internal `ErrorHandler` from a destroyed injector, which would otherwise result in a secondary "destroyed injector" error. The `handleUncaughtError` function is used in a wrapped event listener that invokes the `ErrorHandler` if the listener throws. A simple case in a micro-frontend application: ```ts onNavigationToAnotherApp() { this.appRef.destroy(); do_some_stuff_ie_loggin_that_may_throw(); } ``` If the function throws an error, Angular attempts to inject the `ErrorHandler` from a destroyed injector. PR Close #62275
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit prevents lazy injection of the internal
ErrorHandlerfrom a destroyed injector, which would otherwise result in a secondary "destroyed injector" error.The
handleUncaughtErrorfunction is used in a wrapped event listener that invokes theErrorHandlerif the listener throws. A simple case in a micro-frontend application:If the function throws an error, Angular attempts to inject the
ErrorHandlerfrom a destroyed injector.