Skip to content

Commit 9fc5548

Browse files
antonisclaude
andcommitted
fix(e2e): Retry replay_id check in e2e replay assertion
The captureReplay e2e test fails when replay_id is missing from the error event. This can happen on slow CI when the native replay buffer hasn't captured a frame before the error is sent. Add a retry loop (10 attempts, 3s apart) around the replay_id extraction instead of failing immediately. Reverts the waitForReplayBuffer.yml approach in favour of this simpler server-side retry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0a22be5 commit 9fc5548

3 files changed

Lines changed: 20 additions & 31 deletions

File tree

dev-packages/e2e-tests/maestro/captureReplay.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ jsEngine: graaljs
55
file: utils/launchTestAppClear.yml
66
env:
77
replaysOnErrorSampleRate: 1.0
8-
- runFlow:
9-
file: utils/waitForReplayBuffer.yml
10-
when:
11-
platform: iOS
128
- tapOn: "Capture Exception"
139
- runFlow: utils/assertEventIdVisible.yml
1410
- runFlow:

dev-packages/e2e-tests/maestro/utils/sentryApi.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,27 @@ switch (fetch) {
6565
// The replay_id is set by the SDK on the event before sending (in
6666
// contexts.replay.replay_id or _dsc.replay_id). It should be present
6767
// when the event is fetched from the API.
68-
const event = json(fetchFromSentry(`${baseUrl}/events/${eventId}/json/`));
69-
const rawReplayId = (event.contexts && event.contexts.replay && event.contexts.replay.replay_id)
70-
|| (event._dsc && event._dsc.replay_id);
68+
// Retry a few times: on slow CI the native replay buffer may not have
69+
// captured a frame before the error was sent, so replay_id can be
70+
// missing. Re-fetching gives time for a subsequent event update or
71+
// for eventual consistency in the API.
72+
const REPLAY_ID_RETRIES = 10;
73+
const REPLAY_ID_RETRY_INTERVAL = 3000;
74+
let rawReplayId = null;
75+
for (let attempt = 0; attempt < REPLAY_ID_RETRIES; attempt++) {
76+
const event = json(fetchFromSentry(`${baseUrl}/events/${eventId}/json/`));
77+
rawReplayId = (event.contexts && event.contexts.replay && event.contexts.replay.replay_id)
78+
|| (event._dsc && event._dsc.replay_id);
79+
if (rawReplayId) {
80+
break;
81+
}
82+
if (attempt < REPLAY_ID_RETRIES - 1) {
83+
console.log(`replay_id not yet on event, retrying: ${attempt + 1}/${REPLAY_ID_RETRIES}`);
84+
sleep(REPLAY_ID_RETRY_INTERVAL);
85+
}
86+
}
7187
if (!rawReplayId) {
72-
throw new Error('replay_id not available on the event');
88+
throw new Error('replay_id not available on the event after retries');
7389
}
7490
const replayId = rawReplayId.replace(/\-/g, '');
7591
const replay = json(fetchFromSentry(`${baseUrl}/replays/${replayId}/`));

dev-packages/e2e-tests/maestro/utils/waitForReplayBuffer.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)