Skip to content

Commit 2c3f09c

Browse files
authored
fix(replay): Try/catch sendBufferedReplayOrFlush to prevent cycles (#13900)
It is possible that an error gets thrown outside of flushing (we should be catching exceptions in flush and do no re-throw), which our core SDK error handler would catch due to global rejection handler and trigger replay SDK to flush again.
1 parent 5929a1b commit 2c3f09c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/replay-internal/src/coreHandlers/handleAfterSendEvent.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ function handleErrorEvent(replay: ReplayContainer, event: ErrorEvent): void {
6868
return;
6969
}
7070

71-
setTimeout(() => {
72-
// Capture current event buffer as new replay
73-
// This should never reject
74-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
75-
replay.sendBufferedReplayOrFlush();
71+
setTimeout(async () => {
72+
try {
73+
// Capture current event buffer as new replay
74+
await replay.sendBufferedReplayOrFlush();
75+
} catch (err) {
76+
replay.handleException(err);
77+
}
7678
});
7779
}

0 commit comments

Comments
 (0)