Skip to content

Commit a4bb104

Browse files
committed
browser: Fixed ignoreNextOnError
1 parent b60060d commit a4bb104

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
StackTrace as TraceKitStackTrace,
99
subscribe,
1010
} from '../tracekit';
11+
import { shouldIgnoreOnError } from './helpers';
1112

1213
/** Global handlers */
1314
export class GlobalHandlers implements Integration {
@@ -43,6 +44,9 @@ export class GlobalHandlers implements Integration {
4344
// 9: " foo();"
4445
// 10: " }"
4546
// ]
47+
if (shouldIgnoreOnError()) {
48+
return;
49+
}
4650
captureEvent(this.eventFromGlobalHandler(stack));
4751
});
4852

packages/browser/src/integrations/helpers.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { getCurrentHub } from '@sentry/hub';
2-
import { SentryEvent, SentryWrappedFunction } from '@sentry/types';
2+
import { Mechanism, SentryEvent, SentryWrappedFunction } from '@sentry/types';
33
import { isFunction } from '@sentry/utils/is';
44
import { htmlTreeAsString } from '@sentry/utils/misc';
55

66
const debounceDuration: number = 1000;
77
let keypressTimeout: number | undefined;
88
let lastCapturedEvent: Event | undefined;
9-
let ignoreOnError: number = -1;
10-
11-
// TODO: Fix `ignoreNextOnError`. Just temporary build fix for unused variable
12-
ignoreOnError = ignoreOnError + 1;
9+
let ignoreOnError: number = 0;
1310

11+
/** JSDoc */
12+
export function shouldIgnoreOnError(): boolean {
13+
return ignoreOnError > 0;
14+
}
1415
/** JSDoc */
1516
export function ignoreNextOnError(): void {
1617
// onerror should trigger before setTimeout

0 commit comments

Comments
 (0)