From c1158d88df1587fae43697f9bbc00dc9eb4e2b42 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Wed, 30 Jun 2021 15:39:00 +0100 Subject: [PATCH] Fix an incorrected finish which halted playback prematurely. The scenario was that there were events being rapidly added to the recording. (#606) --- src/replay/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index 0bdd6442..0e5aec9b 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -493,13 +493,16 @@ export class Replayer { this.service.send({ type: 'CAST_EVENT', payload: { event } }); // events are kept sorted by timestamp, check if this is the last event + let last_index = this.service.state.context.events.length - 1; if ( event === - this.service.state.context.events[ - this.service.state.context.events.length - 1 - ] + this.service.state.context.events[last_index] ) { const finish = () => { + if (last_index < this.service.state.context.events.length - 1) { + // more events have been added since the setTimeout + return; + } this.backToNormal(); this.service.send('END'); this.emitter.emit(ReplayerEvents.Finish);