Content-Length: 262719 | pFad | http://github.com/angular/angular/commit/13c53f1379763d2736d638806d440952c36ae7bf

A6 fix(core): avoid injecting internal error handler from a destroyed in… · angular/angular@13c53f1 · GitHub
Skip to content

Commit 13c53f1

Browse files
committed
fix(core): avoid injecting internal error handler from a destroyed injector
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.
1 parent ba75583 commit 13c53f1

File tree

1 file changed

+2
-1
lines changed
  • packages/core/src/render3/instructions

1 file changed

+2
-1
lines changed

packages/core/src/render3/instructions/shared.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,8 @@ export function handleUncaughtError(lView: LView, error: any): void {
699699
if (!injector) {
700700
return;
701701
}
702-
const errorHandler = injector.get(INTERNAL_APPLICATION_ERROR_HANDLER, null);
702+
// TODO(atscott): should we re-throw an error in a `setTimeout` if injector is destroyed?
703+
const errorHandler = injector.get(INTERNAL_APPLICATION_ERROR_HANDLER, null, {optional: true});
703704
errorHandler?.(error);
704705
}
705706

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/angular/commit/13c53f1379763d2736d638806d440952c36ae7bf

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy