Cron: persist manual run marker before unlock (#23993)

* Cron: persist manual run marker before unlock

* Cron tests: relax wakeMode now microtask wait after run lock persist
This commit is contained in:
Tak Hoffman
2026-02-22 18:39:37 -06:00
committed by GitHub
parent 9c87b53c8e
commit 211ab9e4f6
4 changed files with 65 additions and 1 deletions

View File

@@ -226,6 +226,9 @@ export async function run(state: CronServiceState, id: string, mode?: "due" | "f
// (`list`, `status`) stay responsive while the run is in progress.
job.state.runningAtMs = now;
job.state.lastError = undefined;
// Persist the running marker before releasing lock so timer ticks that
// force-reload from disk cannot start the same job concurrently.
await persist(state);
emit(state, { jobId: job.id, action: "started", runAtMs: now });
const executionJob = JSON.parse(JSON.stringify(job)) as typeof job;
return {