@@ -158,8 +158,6 @@ export class ReplayContainer {
158
158
// when an error will occur, so we need to keep a buffer of
159
159
// replay events.
160
160
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 ;
163
161
this . _waitForError = true ;
164
162
}
165
163
@@ -187,6 +185,10 @@ export class ReplayContainer {
187
185
try {
188
186
this . _stopRecording = record ( {
189
187
...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 } ) ,
190
192
emit : this . handleRecordingEmit ,
191
193
} ) ;
192
194
} catch ( err ) {
@@ -470,7 +472,6 @@ export class ReplayContainer {
470
472
this . _stopRecording ( ) ;
471
473
// Reset all "capture on error" configuration before
472
474
// starting a new recording
473
- delete this . recordingOptions . checkoutEveryNms ;
474
475
this . _waitForError = false ;
475
476
this . startRecording ( ) ;
476
477
}
0 commit comments