From 38a9e36b8f63ab79368d416325e7d778f59a4961 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Wed, 1 Apr 2026 12:00:00 +0800 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);