Skip to content

Commit 36ec575

Browse files
authored
fix: Be defensive when iteration over object properties (#1521)
1 parent 3a0565f commit 36ec575

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/browser/src/integrations/helpers.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,15 @@ export function wrap(
8686
}
8787
};
8888

89-
for (const property in fn) {
90-
if (Object.prototype.hasOwnProperty.call(fn, property)) {
91-
wrapped[property] = fn[property];
89+
// Accessing some objects may throw
90+
// ref: https://github.com/getsentry/sentry-javascript/issues/1168
91+
try {
92+
for (const property in fn) {
93+
if (Object.prototype.hasOwnProperty.call(fn, property)) {
94+
wrapped[property] = fn[property];
95+
}
9296
}
93-
}
97+
} catch (_oO) {} // tslint:disable-line:no-empty
9498

9599
wrapped.prototype = fn.prototype;
96100
fn.__sentry_wrapper__ = wrapped;

0 commit comments

Comments
 (0)