fix(scenario-logs): fix out-of-order run log persistence
- Add seq column assigned in call order to fix logs racing each other as fire-and-forget writes (e.g. a snippet's "started" entry could be saved after its "finished" entry) - Log snippet start/finish/failure via context.runSnippet, matching existing step start/pass/fail logging - Rework Markdown log export to per-entry sections instead of a table - Version bump: 1.10.0 -> 1.10.1
This commit is contained in:
1 parent
540a7ec96b
commit
385f51f3ba
6 files changed
+53
-16
No files matched your search
@@ -46,6 +46,9 @@ export class ScenarioSchedulerService implements OnModuleInit {
|
||||
private readonly runScenarioTimeouts = new Map<string, number | null>();
|
||||
// Cache scenarioId per run
|
||||
private readonly runScenarioIds = new Map<string, string>();
|
||||
// Monotonic log sequence per run, since persistLog writes are unawaited and
|
||||
// can otherwise resolve out of call order
|
||||
private readonly runLogSeq = new Map<string, number>();
|
||||
|
||||
private static readonly DEFAULT_SCENARIO_TIMEOUT_SEC = 600;
|
||||
private static readonly DEFAULT_STEP_TIMEOUT_SEC = 60;
|
||||
@@ -138,8 +141,10 @@ export class ScenarioSchedulerService implements OnModuleInit {
|
||||
level: "log" | "warn" | "error",
|
||||
message: string,
|
||||
): void {
|
||||
const seq = (this.runLogSeq.get(runId) ?? 0) + 1;
|
||||
this.runLogSeq.set(runId, seq);
|
||||
void this.runLogRepo.save(
|
||||
this.runLogRepo.create({ runId, stepRunId, level, message }),
|
||||
this.runLogRepo.create({ runId, stepRunId, level, message, seq }),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -216,6 +221,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
|
||||
this.runEnvironments.delete(run.id);
|
||||
this.runScenarioTimeouts.delete(run.id);
|
||||
this.runScenarioIds.delete(run.id);
|
||||
this.runLogSeq.delete(run.id);
|
||||
this.logger.error(
|
||||
`Run #${run.id}: setup failed — ${String(err)}`,
|
||||
);
|
||||
@@ -279,6 +285,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
|
||||
this.runEnvironments.delete(runId);
|
||||
this.runScenarioTimeouts.delete(runId);
|
||||
this.runScenarioIds.delete(runId);
|
||||
this.runLogSeq.delete(runId);
|
||||
await this.maybePreserveSession(runId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user