From 8dbd319bba097c7484c75f96b9fb112ef811b2a8 Mon Sep 17 00:00:00 2001 From: Andrii Arsenin Date: Wed, 15 Apr 2026 18:49:31 +0300 Subject: [PATCH] fix(scenario-runner): preserve session on failed runs - failStepRun was calling closeBrowserHandle immediately, removing the handle before maybePreserveSession could read it in the finally block - delegate browser lifecycle to maybePreserveSession for both pass and fail paths so saveSession=true is honoured regardless of run outcome --- server/src/scenario/scenario-scheduler.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/scenario/scenario-scheduler.service.ts b/server/src/scenario/scenario-scheduler.service.ts index 203c7ed..7b72881 100644 --- a/server/src/scenario/scenario-scheduler.service.ts +++ b/server/src/scenario/scenario-scheduler.service.ts @@ -353,7 +353,9 @@ export class ScenarioSchedulerService { this.logger.log(`Run #${stepRun.runId}: remaining steps cancelled`); - await this.closeBrowserHandle(stepRun.runId); + // Don't close the browser here — maybePreserveSession (called from + // processRunToCompletion's finally block) will either preserve it as a + // session (saveSession=true) or close it (saveSession=false). await this.runRepo.update(stepRun.runId, { status: "fail" }); this.logger.log(`Run #${stepRun.runId} → fail`); }