-
Notifications
You must be signed in to change notification settings - Fork 26.6k
fix(core): avoid injecting internal error handler from a destroyed injector #62275
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
Conversation
13c53f1
to
4c49e1f
Compare
// 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@atscott any more changes required for this change? |
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
JFYI, pushed a rebase to this branch to rerun the CI (it didn't start previously for some reasons). |
…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 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 theErrorHandler
if the listener throws. A simple case in a micro-frontend application:If the function throws an error, Angular attempts to inject the
ErrorHandler
from a destroyed injector.