-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Http request exceptions captured twice in Angular 9 #2532
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
Comments
Thank you for the 🥇 bug report. |
Just collecting my observations so far, if you disable the
|
@kamilogorek do you have a better idea? It seems that by wrapping XHR and/or all other methods this will be reported twice no matter what. We are also not marking the error so we would be able to filter it out in the Angular Error handler. |
It seems like disabling the try/catch integration should be a non-option since that would obviously hide any errors that occur outside of Angular. |
Can we get a sitrep here? I'm a paying customer and timely responses would be appreciated. Thanks! |
That is not accurate. See: #2169 (comment) |
Closing the issue as a part of large repository cleanup, due to it being inactive and/or outdated. |
@kamilogorek this issue is still relevant. For error in http requests, Sentry events are sent twice. You can test it running the stackblitz example i posted in the description, verifying the console.log output. I still think this is an important issue to not pollute the Sentry errors list. Thanks. |
@lujakob thanks for letting me know. Did some debugging around this issue and it appears that There are 2 options. Disabling import * as Sentry from '@sentry/angular';
Sentry.init({
dsn: '...',
integrations: [new Sentry.Integrations.TryCatch({
setTimeout: false,
})]
});
@NgModule({
imports: [ BrowserModule, FormsModule, HttpClientModule ],
declarations: [ AppComponent, HelloComponent ],
providers: [{ provide: ErrorHandler, useValue: Sentry.createErrorHandler() }],
bootstrap: [ AppComponent ]
})
export class AppModule { } or filtering out import * as Sentry from '@sentry/angular';
Sentry.init({
dsn: 'https://[email protected]/1352844',
beforeSend(event, hint) {
// Handled by NgModule's ErrorHandler
if (hint?.originalException instanceof HttpErrorResponse) {
return null;
}
return event;
}
});
@NgModule({
imports: [ BrowserModule, FormsModule, HttpClientModule ],
declarations: [ AppComponent, HelloComponent ],
providers: [{ provide: ErrorHandler, useValue: Sentry.createErrorHandler() }],
bootstrap: [ AppComponent ]
})
export class AppModule { } After update to @sentry/[email protected]: After update to @sentry/[email protected] and using a correct error handler (https://github.com/getsentry/sentry-javascript/tree/master/packages/angular#errorhandler): After update to @sentry/[email protected], using a correct error handler and using Hope that helps! |
@kamilogorek your second proposal using @sentry/angular seems to work. That's awesome, thanks very much. So for me the issue is resolved then. |
Correct, there was none back then :) Glad to hear that, thanks! |
@kamilogorek @sentry/angular continues to report duplicate events for Http errors: https://github.com/pfei5/sentry-duplicate-events.git Sentry.init({
beforeSend(event, hint) {
if (hint?.originalException instanceof HttpErrorResponse) {
return null;
}
return event;
}
}); It is however disconcerting that I need to research for hours to solve a known yet undocumented issue that's been in the wild for years. related: #2744 |
cc @Lms24 |
Package + Version
@sentry/[email protected]
Angular Version 9
Description
Implementing Sentry with Angular following the docs captures two event for http requests that return a 401 error.
I implemented a minimal version in Stackblitz
In app.component.ts a request to a protected API throws a 401 error. The console logs show the beforeSend logs having two events captures, also visible in the networks tab.
Replace the sentry init config dsn to use a different Sentry Account to see the logs in sentry.
If
Sentry.captureException
is outcommented in app.module, still there is one event captured.The text was updated successfully, but these errors were encountered: