Skip to content

Commit 857a688

Browse files
committed
fix(replay): Start replay immediately, not in next tick
This should hopefully fix some race conditions...
1 parent 24dfc66 commit 857a688

File tree

15 files changed

+93
-14
lines changed

15 files changed

+93
-14
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ jobs:
761761
- loader_debug
762762
- loader_tracing
763763
- loader_replay
764+
- loader_replay_buffer
764765
- loader_tracing_replay
765766

766767
steps:

dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/replay/test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { sentryTest } from '../../../../utils/fixtures';
44
import { getReplayEvent, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers';
55

66
sentryTest('should capture a replay', async ({ getLocalTestUrl, page }) => {
7-
if (shouldSkipReplayTest()) {
7+
// When in buffer mode, there will not be a replay by default
8+
if (shouldSkipReplayTest() || process.env.PW_BUNDLE === 'loader_replay_buffer') {
89
sentryTest.skip();
910
}
1011

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.doSomethingWrong();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
5+
import { getReplayEvent, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers';
6+
7+
sentryTest('should capture a replay & attach an error', async ({ getLocalTestUrl, page }) => {
8+
if (shouldSkipReplayTest()) {
9+
sentryTest.skip();
10+
}
11+
12+
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
13+
return route.fulfill({
14+
status: 200,
15+
contentType: 'application/json',
16+
body: JSON.stringify({ id: 'test-id' }),
17+
});
18+
});
19+
20+
const req = waitForReplayRequest(page);
21+
22+
const url = await getLocalTestUrl({ testDir: __dirname });
23+
const reqError = await waitForErrorRequestOnUrl(page, url);
24+
25+
const errorEventData = envelopeRequestParser(reqError);
26+
expect(errorEventData.exception?.values?.length).toBe(1);
27+
expect(errorEventData.exception?.values?.[0]?.value).toBe('window.doSomethingWrong is not a function');
28+
29+
const eventData = getReplayEvent(await req);
30+
31+
expect(eventData).toBeDefined();
32+
expect(eventData.segment_id).toBe(0);
33+
34+
expect(errorEventData.tags?.replayId).toEqual(eventData.replay_id);
35+
});

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customReplay/init.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ Sentry.onLoad(function () {
66
useCompression: false,
77
}),
88
],
9+
10+
replaysSessionSampleRate: 1,
911
});
1012
});
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Sentry.onLoad(function () {
2-
Sentry.init({});
2+
Sentry.init({
3+
replaysSessionSampleRate: 1,
4+
});
35
});

dev-packages/browser-integration-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"test:loader:eager": "PW_BUNDLE=loader_eager yarn test:loader",
3333
"test:loader:tracing": "PW_BUNDLE=loader_tracing yarn test:loader",
3434
"test:loader:replay": "PW_BUNDLE=loader_replay yarn test:loader",
35+
"test:loader:replay_buffer": "PW_BUNDLE=loader_replay_buffer yarn test:loader",
3536
"test:loader:full": "PW_BUNDLE=loader_tracing_replay yarn test:loader",
3637
"test:loader:debug": "PW_BUNDLE=loader_debug yarn test:loader",
3738
"test:ci": "yarn test:all --reporter='line'",

0 commit comments

Comments
 (0)