Skip to content

Commit b92d32b

Browse files
committed
fix: Dont capture our own XHR events that somehow bubbled-up to global handler
1 parent f71c174 commit b92d32b

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Unreleased
44

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

77
## 5.6.2
88

packages/browser/src/integrations/globalhandlers.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export class GlobalHandlers implements Integration {
5656
Error.stackTraceLimit = 50;
5757

5858
_subscribe((stack: TraceKitStackTrace, _: boolean, error: any) => {
59-
if (shouldIgnoreOnError()) {
59+
const isFailedOwnDelivery = error && error.__sentry_own_request__ === true;
60+
if (shouldIgnoreOnError() || isFailedOwnDelivery) {
6061
return;
6162
}
6263
const self = getCurrentHub().getIntegration(GlobalHandlers);

packages/browser/test/integration/suites/builtins.js

+20
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,26 @@ describe("wrapped built-ins", function() {
304304
}
305305
});
306306
});
307+
308+
it("should skip our own failed requests that somehow bubbled-up to unhandledrejection handler", function() {
309+
return runInSandbox(sandbox, function() {
310+
if (isChrome()) {
311+
Promise.reject({
312+
__sentry_own_request__: true,
313+
});
314+
Promise.reject({
315+
__sentry_own_request__: false,
316+
});
317+
Promise.reject({});
318+
} else {
319+
window.resolveTest({ window: window });
320+
}
321+
}).then(function(summary) {
322+
if (summary.window.isChrome()) {
323+
assert.equal(summary.events.length, 2);
324+
}
325+
});
326+
});
307327
});
308328

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

0 commit comments

Comments
 (0)