8000 ref(replay): Avoid overwriting user `checkoutEveryNms` config (#6454) · vaind/sentry-javascript@667edd6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 667edd6

Browse files
authored
ref(replay): Avoid overwriting user checkoutEveryNms config (getsentry#6454)
1 parent 00dca28 commit 667edd6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/replay/src/replay.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ export class ReplayContainer {
158158
// when an error will occur, so we need to keep a buffer of
159159
// replay events.
160160
if (this.session.sampled === 'error') {
161-
// Checkout every minute, meaning we only get up-to one minute of events before the error happens
162-
this.recordingOptions.checkoutEveryNms = 60000;
163161
this._waitForError = true;
164162
}
165163

@@ -187,6 +185,10 @@ export class ReplayContainer {
187185
try {
188186
this._stopRecording = record({
189187
...this.recordingOptions,
188+
// When running in error sampling mode, we need to overwrite `checkoutEveryNth`
189+
// Without this, it would record forever, until an error happens, which we don't want
190+
// instead, we'll always keep the last 60 seconds of replay before an error happened
191+
...(this._waitForError && { checkoutEveryNth: 60000 }),
190192
emit: this.handleRecordingEmit,
191193
});
192194
} catch (err) {
@@ -470,7 +472,6 @@ export class ReplayContainer {
470472
this._stopRecording();
471473
// Reset all "capture on error" configuration before
472474
// starting a new recording
473-
delete this.recordingOptions.checkoutEveryNms;
474475
this._waitForError = false;
475476
this.startRecording();
476477
}

0 commit comments

Comments
 (0)
0