From 5637a130030423e9e14ac50137657250d13926b3 Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Wed, 25 Feb 2026 13:16:51 +0100 Subject: [PATCH] fix: guard timestamp recording against cross-session contamination If recording is stopped and restarted inside the same execute() call, the finally block could append an interval from the old recording into the new recording's executionTimestamps. Fix by comparing against the snapshotted recordingStartedAt instead of just checking non-null. --- playwriter/src/executor.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/playwriter/src/executor.ts b/playwriter/src/executor.ts index 16ab6f2..8d79c7f 100644 --- a/playwriter/src/executor.ts +++ b/playwriter/src/executor.ts @@ -1050,7 +1050,9 @@ export class PlaywrightExecutor { } finally { // Record timestamp even on error — the execution still occupied real time // that should not be sped up in the demo video. - if (recordingStartSnapshot !== null && execStartSec >= 0 && this.recordingStartedAt !== null) { + // Compare against snapshot to avoid cross-session contamination if + // recording was stopped and restarted inside the same execute() call. + if (recordingStartSnapshot !== null && execStartSec >= 0 && this.recordingStartedAt === recordingStartSnapshot) { const execEndSec = (Date.now() - recordingStartSnapshot) / 1000 this.executionTimestamps.push({ start: execStartSec, end: execEndSec }) }