Skip to content

Commit b744494

Browse files
billyvgmydea
authored andcommitted
errorHandler should only annotate error, we want it to re-throw so do not return true
1 parent 7e851da commit b744494

File tree

3 files changed

+53
-13
lines changed

3 files changed

+53
-13
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
</head>
6+
<body>
7+
</body>
8+
</html>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { expect } from '@playwright/test';
2+
import { SDK_VERSION } from '@sentry/browser';
3+
4+
import { sentryTest } from '../../../utils/fixtures';
5+
import { getReplayEvent, shouldSkipReplayTest, waitForReplayRequest } from '../../../utils/replayHelpers';
6+
7+
sentryTest('exceptions within rrweb and re-thrown and annotated', async ({ getLocalTestPath, page, browserName}) => {
8+
if (shouldSkipReplayTest() || browserName !== 'chromium') {
9+
sentryTest.skip();
10+
}
11+
12+
// const reqPromise0 = waitForReplayRequest(page, 0);
13+
// const reqPromise1 = waitForReplayRequest(page, 1);
14+
//
15+
// await page.route('https://dsn.ingest.sentry.io/**/*', route => {
16+
// return route.fulfill({
17+
// status: 200,
18+
// contentType: 'application/json',
19+
// body: JSON.stringify({ id: 'test-id' }),
20+
// });
21+
// });
22+
//
23+
const url = await getLocalTestPath({ testDir: __dirname });
24+
25+
await page.goto(url);
26+
27+
expect(await page.evaluate(() => {
28+
try {
29+
const s = new CSSStyleSheet();
30+
s.insertRule('body::-ms-expand{display: none}');
31+
s.insertRule('body {background-color: #fff;}');
32+
return s.cssRules.length;
33+
} catch {
34+
return false;
35+
}
36+
})).toBe(false);
37+
38+
expect(await page.evaluate(() => {
39+
const s = new CSSStyleSheet();
40+
s.insertRule('body {background-color: #fff;}');
41+
return s.cssRules.length;
42+
})).toBe(1);
43+
})

packages/replay/src/integration.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,8 @@ export class Replay implements Integration {
145145
// collect fonts, but be aware that `sentry.io` needs to be an allowed
146146
// origin for playback
147147
collectFonts: true,
148-
errorHandler: (err: Error & {__rrweb__?: boolean, __source__?: string}) => {
149-
try {
150-
err.__rrweb__ = true;
151-
152-
// Re-throw as styled-components relies on thrown exception when CSS rule fails to be inserted.
153-
if (err.__source__ === 'CSSStyleSheet.insertRule') {
154-
throw err;
155-
}
156-
} catch {
157-
// avoid any potential hazards here
158-
}
159-
// return true to suppress throwing the error inside of rrweb
160-
return true;
148+
errorHandler: (err: Error & {__rrweb__?: boolean}) => {
149+
err.__rrweb__ = true;
161150
},
162151
};
163152

0 commit comments

Comments
 (0)