Error Handler Service 'insider/client' exceptions (of type 'Error') not working when lazy loaded by parent application

This issue has been created since 2022-09-20.

Which @angular/* package(s) are the source of the bug?


Is this a regression?



We have multiple engineering groups working independently building Angular modules (NgModules). We keep these modules entirely independent and self-sufficient and, as such, have their own ErrorHandler overrides. The modules are route lazy loaded as needed into parent apps that require their functionality. Note, although not relevant, the modules are federated (see webpack) and are lazy loaded from other machines. But, for now, we don't believe their federation is the root cause of the issue.

The ErrorHandlers work fine and catch insider/client 'Error's when running in their own standalone apps. However, when loaded into the parent app which DOES NOT OVERRIDE their ErrorHandler's service, the insider Errors are not caught. Important NOTE: The HTTPResponse/HttpErrorResponse, errors (ie outsider/server errors) ARE caught since each independent module calls their overridden ErrorHandler actively via the standard interceptor model-unike the insider/client errors that are called by Angular.

However, when we add an ErrorHandler to the parent, the insider/client Error exceptions do start getting called. Which subverts the modularity required and separation of concerns of our modules. Note, it seems the ErrorHandler must provided at 'root' of any app that requires this feature. Submodules that have that feature are not invoked (except for outsider/server errors).

It 'seems the ErrorHandl

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular 12.2.12

Anything else?

No response

pkozlowski-opensource wrote this answer on 2022-09-20

I think that this issue steams from the assumptions that are not corresponding to the Angular's DI design and implementation:

  • DI tokens (including ErrorHandler) are not scoped to NgModule - instead those are merged / overriden;
  • the expectation is that there is one and only one ErrorHandler in the entire Angular application. We do not intend to support per-NgModule error handlers / more than one ErrorHandler per application.

Closing as not something we intend to support.

momoadeli wrote this answer on 2022-09-20

@pkozlowski-opensource Many thanks. Seems there are architectural obstacles that prohibit this. What is the root rationale ErrorHandler is not provided at module level but at app root once? Can you provide thoughts so we can internally close this thinking and not attempt to write our own?

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-10-04
Star Count 84139
Watcher Count 3064
Fork Count 22243
Issue Count 1206


Issue Title Created Date Comment Count Updated Date
kubevela app exist ,but commponent in k8s cluster disappear 6 2022-08-30 2022-09-10
Crash consistency bug in 3.2-nvml 0 2021-05-03 2022-09-08
Stork-scheduler missing flag on kube-scheduler-amd64 1 2021-08-10 2022-03-21
Dragging bars does not seem to work 3 2021-05-19 2022-07-15
Use white-space: pre-wrap for the results 1 2021-03-11 2022-08-26
fatal error: NvInfer.h: No such file or directory 2 2021-04-17 2022-10-02
BA.5.2.1 with S:1020V [120 seq as of 2022-09-05, sudden increase in Switzerland, present in US, Australia, &co 1 2022-09-05 2022-09-23
[QUESTION] How to tag stratospheric ozone with UCX enabled? 4 2022-02-14 2022-04-15
upload restart when finished 5 2021-08-20 2022-09-07
CarPlay doesn't show song 3 2022-03-19 2022-09-12
Error 1 compilation failed for "RcppTOML" when install.packages("Seurat") is run 6 2022-02-23 2022-09-15
[Bug Report] Message components buttons not colored 8 2022-01-28 2022-09-30
Bug: Can't chain filters. AND operation doesn't work for ManyToMany field. 1 2022-01-06 2022-09-08
Support for Visual Studio 2022 5 2021-09-18 2022-09-13
Keyboard casing issue uppercased acts like capsLocked in text proxies 6 2021-07-11 2022-09-29
Font Request: GNU Unifont 5 2021-08-30 2022-08-07
Refactor the calculation of the greek parameters (kappa, gamma and eta) 4 2021-10-27 2021-11-16
Are these models trained with Caucasian faces? 0 2022-03-18 2022-09-17
ABTest是机器学习的内容吗 1 2021-10-12 2022-01-16
A lot of notification with 'Device not ready' popping up 0 2021-10-20 2022-09-28
Error: EACCES, permission denied '/root/.config/configstore/insight-yo.json' 37 2015-08-01 2022-09-22
Force top level classes in jaxb bindings 0 2018-04-23 2022-07-18
Failed to decode json returned from code runner 6 2021-02-03 2022-09-15
[🐛 Bug]: In selenium grid 4 , selenium test is running only in headless mode for chrome driver 3 2022-08-04 2022-09-03
[Bug]: API & Query fields don't expand correctly 0 2021-10-27 2022-09-11
Mocking Access Token auth - jose.exceptions.JWSError: This is not a private key 2 2021-10-12 2022-09-14
120hz support when scrolling 6 2021-11-18 2022-08-26
enum type is used as the primary key, not in is used as the query condition, and the null value is incorrectly returned 0 2021-09-30 2022-08-14
Release version not being read from assembly and defaulting to 1.0.0 6 2022-03-18 2022-09-13
Current AwsRequestSigningApacheInterceptor removes request content 0 2022-08-23 2022-09-01
endDocument possible wrong 1 2022-08-19 2022-09-27 0 2022-01-11 2022-01-21
Avoid compilation of graylog2-server for web plugins 2 2021-12-21 2022-09-30
v8.11.2: possible lcms2 problems with 32-bit static build 6 2021-07-14 2022-09-01
Bulk trait update should support `[]Trait` as input 0 2021-04-15 2022-09-19
Add boolean to Organisation to define create new project permission 2 2021-10-01 2022-09-23
Build and run instructions 3 2021-01-15 2022-09-22
Show the rule ID when an issue is found 0 2020-09-10 2022-09-22
How Can i use pretrained models like SAST EAST in pdserving? 5 2021-10-25 2022-07-22
load text_loader.json as a file if cannot be found as a resource 0 2022-03-02 2022-09-22
thAttrs/tdAttrs leads to recursive updates 0 2022-08-03 2022-09-24
fileType .vue template indent 2 2022-05-09 2022-09-27
Doc suggestions: disable CDN and include/exculde files 0 2014-06-16 2022-10-03
Hide Lorca's Windows command prompt 1 2021-12-09 2022-09-26
Error: initial journal cursor: failed to get cursor: cannot assign requested address 42 2021-10-18 2022-09-30
Error: OCI runtime error: the container is paused, when trying to exec into container (container-in-container, rootless) 4 2021-10-18 2022-08-13
Selectively enable CRD definitions in Cluster via a value in the value.yaml file 4 2021-07-09 2022-09-21
[Synthetics UI] [Overview] Error overlay 1 2022-06-24 2022-08-01
QuerydslMongoPredicateExecutor findAll() tries to get offset for a Pageable.unpaged() 3 2021-07-26 2022-09-24
`Model.update_all(attribute: interval_expression)` sets the wrong date when using Postgres' interval expressions 7 2022-07-25 2022-08-29