fix: prevent cron jobs from skipping execution when nextRunAtMs advances (#14068)

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
WalterSumbon
2026-02-12 13:33:22 +08:00
committed by GitHub
parent a88ea42ec7
commit 39e3d58fe1
3 changed files with 187 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import {
computeJobNextRunAtMs,
nextWakeAtMs,
recomputeNextRuns,
recomputeNextRunsForMaintenance,
resolveJobPayloadTextForMain,
} from "./jobs.js";
import { locked } from "./locked.js";
@@ -187,7 +188,10 @@ export async function onTimer(state: CronServiceState) {
const due = findDueJobs(state);
if (due.length === 0) {
const changed = recomputeNextRuns(state);
// Use maintenance-only recompute to avoid advancing past-due nextRunAtMs
// values without execution. This prevents jobs from being silently skipped
// when the timer wakes up but findDueJobs returns empty (see #13992).
const changed = recomputeNextRunsForMaintenance(state);
if (changed) {
await persist(state);
}