Title: Angular - errors are reported multiple times · Issue #2744 · getsentry/sentry-javascript · GitHub
Open Graph Title: Angular - errors are reported multiple times · Issue #2744 · getsentry/sentry-javascript
X Title: Angular - errors are reported multiple times · Issue #2744 · getsentry/sentry-javascript
Description: Package + Version @sentry/browser @sentry/integrations Version: ^5.19.1 Description I'm having an issue with errors being reported multiple times. One error is correctly catched via angular ErrorHandler, second one is catched by captureE...
Open Graph Description: Package + Version @sentry/browser @sentry/integrations Version: ^5.19.1 Description I'm having an issue with errors being reported multiple times. One error is correctly catched via angular ErrorHa...
X Description: Package + Version @sentry/browser @sentry/integrations Version: ^5.19.1 Description I'm having an issue with errors being reported multiple times. One error is correctly catched via angular Err...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/2744
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Angular - errors are reported multiple times","articleBody":"## Package + Version\r\n\r\n- [x] `@sentry/browser`\r\n- [x] `@sentry/integrations`\r\n\r\n### Version:\r\n\r\n```\r\n^5.19.1\r\n```\r\n\r\n## Description\r\n\r\nI'm having an issue with errors being reported multiple times. One error is correctly catched via angular ErrorHandler, second one is catched by `captureException` executed inside `sentryWrapped` function. \r\n\r\nI tried proposed solution for angular, shown below:\r\n\r\n```\r\n// TryCatch has to be configured to disable XMLHttpRequest wrapping, as we are going to handle\r\n// http module exceptions manually in Angular's ErrorHandler and we don't want it to capture the same error twice.\r\n// Please note that TryCatch configuration requires at least @sentry/browser v5.16.0.\r\nintegrations: [new Sentry.Integrations.TryCatch({\r\n XMLHttpRequest: false,\r\n})],\r\n```\r\n\r\nbut it didn't help. To block additional error reports I had to set:\r\n```\r\nsetTimeout: false\r\n```\r\n\r\nIt's just a workaround that I'd rather not use, since errors may also occur outside angular.\r\n\r\nI started debugging which `setTimeout` was the root cause of duplicated reports. I found that it's caused by `hostReportError` from rxjs ( https://github.com/ReactiveX/rxjs/blob/f5278aa89ea164caf5cf10e77d7bd00eff26fc0f/src/internal/util/hostReportError.ts#L6 ) \r\n\r\nStarting from rxjs v6.0.0 they changed the way of reporting the errors from sync to async mode. \r\n> error handling: Unhandled errors are no longer caught and rethrown, rather they are caught and scheduled to be thrown, which causes them to be reported to window.onerror or process.on('error'), depending on the environment.\r\n_https://github.com/ReactiveX/rxjs/blob/master/CHANGELOG.md#breaking-changes-10_\r\n\r\nAs a part from investigation I tried to switch back to sync error reporting (using rxjs `config.useDeprecatedSynchronousErrorHandling = true`).\r\n\r\nAfter this change, to stop duplicated error reports I had to set TryCatch options to `eventTarget: false` (`setTimeout: false` was no more needed). \r\n\r\nSeems that Sentry is wrapping `addEventListener` for angular http client https://github.com/angular/angular/blob/master/packages/common/http/src/xhr.ts#L311. Setting `XMLHttpRequest: false` doesn't work. \r\n\r\nAs a temporary fix I'll probably check error report in `beforeSend` and skip unwanted ones, but could you fix it internally? Thanks :) \r\n\r\n### Related issues\r\nhttps://github.com/getsentry/sentry-javascript/issues/2533\r\nhttps://github.com/getsentry/sentry-javascript/issues/2532\r\nhttps://github.com/getsentry/sentry-javascript/issues/2169","author":{"url":"https://github.com/kamilchlebek","@type":"Person","name":"kamilchlebek"},"datePublished":"2020-07-15T11:00:02Z","url":"https://github.com/getsentry/sentry-javascript/issues/2744"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d5dd6cef-c037-34c6-1f5b-258167a7b01b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E40C:3F5E9C:37C90CD:4913B1F:6B04417B |
| html-safe-nonce | d151d61466cc3cb4c8eb1eca364cccf26229cf0a3dae99dcc0d68ea444a6396c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDBDOjNGNUU5QzozN0M5MENEOjQ5MTNCMUY6NkIwNDQxN0IiLCJ2aXNpdG9yX2lkIjoiODQxMDYyODY4NTY2OTA4OTY2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3ca026327eb69ebe31df54ea3018b30b262a00bce892dd4fe8a53c6819d2a5db |
| hovercard-subject-tag | issue:657260935 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/2744/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a93d3912d21871699085ec57f248e0d5c6d7bc604c68725e28d8218a4496b929/getsentry/sentry-javascript/issues/2744 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a93d3912d21871699085ec57f248e0d5c6d7bc604c68725e28d8218a4496b929/getsentry/sentry-javascript/issues/2744 |
| og:image:alt | Package + Version @sentry/browser @sentry/integrations Version: ^5.19.1 Description I'm having an issue with errors being reported multiple times. One error is correctly catched via angular ErrorHa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kamilchlebek |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width