Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(replay): Fix potential broken CSS in styled-components #9234

Merged
merged 4 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../utils/fixtures';
import { shouldSkipReplayTest } from '../../../utils/replayHelpers';

sentryTest('exceptions within rrweb and re-thrown and annotated', async ({ getLocalTestPath, page, browserName }) => {
if (shouldSkipReplayTest() || browserName !== 'chromium') {
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);

expect(
await page.evaluate(() => {
try {
const s = new CSSStyleSheet();
s.insertRule('body::-ms-expand{display: none}');
s.insertRule('body {background-color: #fff;}');
return s.cssRules.length;
} catch {
return false;
}
}),
).toBe(false);

expect(
await page.evaluate(() => {
const s = new CSSStyleSheet();
s.insertRule('body {background-color: #fff;}');
return s.cssRules.length;
}),
).toBe(1);
});
10 changes: 4 additions & 6 deletions packages/replay/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,13 @@ export class Replay implements Integration {
// collect fonts, but be aware that `sentry.io` needs to be an allowed
// origin for playback
collectFonts: true,
errorHandler: (err: Error) => {
errorHandler: (err: Error & { __rrweb__?: boolean }) => {
try {
// @ts-expect-error Set this so that replay SDK can ignore errors originating from rrweb
err.__rrweb__ = true;
} catch {
// avoid any potential hazards here
} catch (error) {
// ignore errors here
// this can happen if the error is frozen or does not allow mutation for other reasons
}
// return true to suppress throwing the error inside of rrweb
return true;
},
};

Expand Down