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
This commit is contained in:
2026-04-15 18:49:31 +03:00
parent 67e230a647
commit 8dbd319bba
@@ -353,7 +353,9 @@ export class ScenarioSchedulerService {
this.logger.log(`Run #${stepRun.runId}: remaining steps cancelled`); 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" }); await this.runRepo.update(stepRun.runId, { status: "fail" });
this.logger.log(`Run #${stepRun.runId} → fail`); this.logger.log(`Run #${stepRun.runId} → fail`);
} }