Skip to content

Commit

Permalink
fix: Dont capture our own XHR events that somehow bubbled-up to globa…
Browse files Browse the repository at this point in the history
…l handler
  • Loading branch information
kamilogorek committed Aug 29, 2019
1 parent f71c174 commit b92d32b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

- This slot is waiting for you
- [browser] fix: Don't capture our own XHR events that somehow bubbled-up to global handler

## 5.6.2

Expand Down
3 changes: 2 additions & 1 deletion packages/browser/src/integrations/globalhandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export class GlobalHandlers implements Integration {
Error.stackTraceLimit = 50;

_subscribe((stack: TraceKitStackTrace, _: boolean, error: any) => {
if (shouldIgnoreOnError()) {
const isFailedOwnDelivery = error && error.__sentry_own_request__ === true;
if (shouldIgnoreOnError() || isFailedOwnDelivery) {
return;
}
const self = getCurrentHub().getIntegration(GlobalHandlers);
Expand Down
20 changes: 20 additions & 0 deletions packages/browser/test/integration/suites/builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,26 @@ describe("wrapped built-ins", function() {
}
});
});

it("should skip our own failed requests that somehow bubbled-up to unhandledrejection handler", function() {
return runInSandbox(sandbox, function() {
if (isChrome()) {
Promise.reject({
__sentry_own_request__: true,
});
Promise.reject({
__sentry_own_request__: false,
});
Promise.reject({});
} else {
window.resolveTest({ window: window });
}
}).then(function(summary) {
if (summary.window.isChrome()) {
assert.equal(summary.events.length, 2);
}
});
});
});

it("should capture exceptions inside setTimeout", function() {
Expand Down

0 comments on commit b92d32b

Please sign in to comment.