Skip to content

Commit 2ff420e

Browse files
sodHazAT
authored andcommitted
fix: don't call fn.handleEvent.bind if fn.handleEvent does not exist (getsentry#2138)
1 parent 4bfbf99 commit 2ff420e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

packages/browser/src/integrations/trycatch.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,19 @@ export class TryCatch implements Integration {
7070
options?: boolean | AddEventListenerOptions,
7171
): (eventName: string, fn: EventListenerObject, capture?: boolean, secure?: boolean) => void {
7272
try {
73-
fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
74-
mechanism: {
75-
data: {
76-
function: 'handleEvent',
77-
handler: getFunctionName(fn),
78-
target,
73+
if (typeof fn.handleEvent === 'function') {
74+
fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
75+
mechanism: {
76+
data: {
77+
function: 'handleEvent',
78+
handler: getFunctionName(fn),
79+
target,
80+
},
81+
handled: true,
82+
type: 'instrument',
7983
},
80-
handled: true,
81-
type: 'instrument',
82-
},
83-
});
84+
});
85+
}
8486
} catch (err) {
8587
// can sometimes get 'Permission denied to access property "handle Event'
8688
}

0 commit comments

Comments
 (0)