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

Information during compilation sent to ErrorHandler. Why? Can this be avoided? #37468

Closed
mdmoura opened this issue Jun 5, 2020 · 5 comments
Closed
Labels
area: core Issues related to the framework runtime core: error handling needs reproduction This issue needs a reproduction in order for the team to investigate further
Milestone

Comments

@mdmoura
Copy link

mdmoura commented Jun 5, 2020

I implemented a custom ErrorHandler in Angular 9 to log errors to an API endpoint:

@Injectable()
export class GlobalErrorHandler extends ErrorHandler {

  constructor(private logService: LogApiService) {
    super();
  }

  handleError(error: any) {
    if (error instanceof Error) {
      try {
        let request: LogApiRequest = { 
          level: 'Error', 
          message: error.message,
          stack: error.stack
        };
        this.logService.send(request).subscribe();  
      } catch (error) {
        super.handleError(error);
      }
    }
    super.handleError(error);
  }
}

When I run the application I get a around 200 errors logged on the API like this one:

[webpack.Progress] 98% after emitting angular-compiler

I believe this is during compilation but it creates around 200 records on the database.

Should this messages be considered errors? Can this be avoided?

Angular Version:


Angular CLI: 9.1.1
Node: 13.5.0
OS: darwin x64

Angular: 9.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes

Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.901.4
@angular-devkit/build-angular              0.901.4
@angular-devkit/build-optimizer            0.901.4
@angular-devkit/build-webpack              0.901.4
@angular-devkit/core                       9.1.4
@angular-devkit/schematics                 9.1.1
@ngtools/webpack                           9.1.4
@nguniversal/module-map-ngfactory-loader   8.1.1
@schematics/angular                        9.1.1
@schematics/update                         0.901.1
rxjs                                       6.5.5
typescript                                 3.8.3
webpack                                    4.42.0
@pkozlowski-opensource pkozlowski-opensource added area: core Issues related to the framework runtime core: error handling labels Jun 8, 2020
@ngbot ngbot bot modified the milestone: needsTriage Jun 8, 2020
@pkozlowski-opensource
Copy link
Member

@mdmoura ideally we would need a reproduce scenario as there is not enough info here (how do you register error handler, do you build with the CLI or do you have any custom build extensions etc.). Could you please share a minimal GitHub repo demonstrating the issue?

Also, I'm a bit confused by the information you've provided since in the description you are mentioning Angular 9 while the version shared indicate Angular 8.

@pkozlowski-opensource pkozlowski-opensource added the needs reproduction This issue needs a reproduction in order for the team to investigate further label Jun 8, 2020
@mdmoura
Copy link
Author

mdmoura commented Jun 8, 2020

@pkozlowski-opensource Sorry, I copied the wrong Angular's version information on my first question. I just updated ...

I am registering the ErrorHandler in AppModule (Omitted imports, etc for simplicity):

@NgModule({
  providers: [
    { provide: ErrorHandler, useClass: GlobalErrorHandler }
  ],
  bootstrap: [AppComponent]
})

I created my Angular's project simply by using the ng new command.

When I created the ErrorHandler as I mentioned ... I will try to create a sample project.

@pkozlowski-opensource
Copy link
Member

. I will try to create a sample project.

Yes, please! And please include exact commands you run to reproduce

@pkozlowski-opensource
Copy link
Member

I'm going to close this issue for now as we haven't heard back with the reproduce scenario. Happy to re-open if / when we've got one.

@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 Aug 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: error handling needs reproduction This issue needs a reproduction in order for the team to investigate further
Projects
None yet
Development

No branches or pull requests

2 participants