Skip to content

Commit d42a724

Browse files
committed
prevent exceptions being captured more than once
1 parent c8ccec8 commit d42a724

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/core/src/baseclient.ts

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Transport,
1414
} from '@sentry/types';
1515
import {
16+
checkOrSetAlreadyCaught,
1617
dateTimestampInSeconds,
1718
Dsn,
1819
isPlainObject,
@@ -101,6 +102,11 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
101102
*/
102103
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
103104
public captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined {
105+
// ensure we haven't captured this very object before
106+
if (checkOrSetAlreadyCaught(exception)) {
107+
return;
108+
}
109+
104110
let eventId: string | undefined = hint && hint.event_id;
105111

106112
this._process(
@@ -140,6 +146,11 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
140146
* @inheritDoc
141147
*/
142148
public captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined {
149+
// ensure we haven't captured this very object before
150+
if (hint?.originalException && checkOrSetAlreadyCaught(hint.originalException)) {
151+
return;
152+
}
153+
143154
let eventId: string | undefined = hint && hint.event_id;
144155

145156
this._process(

0 commit comments

Comments
 (0)