@@ -209,12 +209,18 @@ export class ReplayContainer implements ReplayContainerInterface {
209
209
* Returns true if it was stopped, else false.
210
210
*/
211
211
public stopRecording ( ) : boolean {
212
- if ( this . _stopRecording ) {
213
- this . _stopRecording ( ) ;
214
- return true ;
215
- }
212
+ try {
213
+ if ( this . _stopRecording ) {
214
+ this . _stopRecording ( ) ;
215
+ this . _stopRecording = undefined ;
216
+ return true ;
217
+ }
216
218
217
- return false ;
219
+ return false ;
220
+ } catch ( err ) {
221
+ this . _handleException ( err ) ;
222
+ return false ;
223
+ }
218
224
}
219
225
220
226
/**
@@ -226,7 +232,7 @@ export class ReplayContainer implements ReplayContainerInterface {
226
232
__DEBUG_BUILD__ && logger . log ( '[Replay] Stopping Replays' ) ;
227
233
this . _isEnabled = false ;
228
234
this . _removeListeners ( ) ;
229
- this . _stopRecording && this . _stopRecording ( ) ;
235
+ this . stopRecording ( ) ;
230
236
this . eventBuffer && this . eventBuffer . destroy ( ) ;
231
237
this . eventBuffer = null ;
232
238
this . _debouncedFlush . cancel ( ) ;
@@ -242,14 +248,7 @@ export class ReplayContainer implements ReplayContainerInterface {
242
248
*/
243
249
public pause ( ) : void {
244
250
this . _isPaused = true ;
245
- try {
246
- if ( this . _stopRecording ) {
247
- this . _stopRecording ( ) ;
248
- this . _stopRecording = undefined ;
249
- }
250
- } catch ( err ) {
251
- this . _handleException ( err ) ;
252
- }
251
+ this . stopRecording ( ) ;
253
252
}
254
253
255
254
/**
@@ -634,8 +633,12 @@ export class ReplayContainer implements ReplayContainerInterface {
634
633
* create a new Replay event.
635
634
*/
636
635
private _triggerFullSnapshot ( ) : void {
637
- __DEBUG_BUILD__ && logger . log ( '[Replay] Taking full rrweb snapshot' ) ;
638
- record . takeFullSnapshot ( true ) ;
636
+ try {
637
+ __DEBUG_BUILD__ && logger . log ( '[Replay] Taking full rrweb snapshot' ) ;
638
+ record . takeFullSnapshot ( true ) ;
639
+ } catch ( err ) {
640
+ this . _handleException ( err ) ;
641
+ }
639
642
}
640
643
641
644
/**
0 commit comments