Skip to content

Commit

Permalink
fix(replay): Try/catch sendBufferedReplayOrFlush to prevent cycles (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
billyvg authored Oct 8, 2024
1 parent 5929a1b commit 2c3f09c
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ function handleErrorEvent(replay: ReplayContainer, event: ErrorEvent): void {
return;
}

setTimeout(() => {
// Capture current event buffer as new replay
// This should never reject
// eslint-disable-next-line @typescript-eslint/no-floating-promises
replay.sendBufferedReplayOrFlush();
setTimeout(async () => {
try {
// Capture current event buffer as new replay
await replay.sendBufferedReplayOrFlush();
} catch (err) {
replay.handleException(err);
}
});
}

0 comments on commit 2c3f09c

Please sign in to comment.