fix: recompute all cron next-run times after job update (openclaw#15905) thanks @echoVic

Verified:
- pnpm check
- pnpm vitest src/cron/service.issue-regressions.test.ts src/cron/service.issue-13992-regression.test.ts

Co-authored-by: echoVic <16428813+echoVic@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
青雲
2026-02-15 02:37:22 +08:00
committed by GitHub
parent 9409942de4
commit 80407cbc6a
3 changed files with 87 additions and 1 deletions

View File

@@ -119,7 +119,7 @@ export async function add(state: CronServiceState, input: CronJobCreate) {
export async function update(state: CronServiceState, id: string, patch: CronJobPatch) {
return await locked(state, async () => {
warnIfDisabled(state, "update");
await ensureLoaded(state);
await ensureLoaded(state, { skipRecompute: true });
const job = findJobOrThrow(state, id);
const now = state.deps.nowMs();
applyJobPatch(job, patch);
@@ -150,6 +150,13 @@ export async function update(state: CronServiceState, id: string, patch: CronJob
job.state.nextRunAtMs = undefined;
job.state.runningAtMs = undefined;
}
} else if (job.enabled) {
// Non-schedule edits should not mutate other jobs, but still repair a
// missing/corrupt nextRunAtMs for the updated job.
const nextRun = job.state.nextRunAtMs;
if (typeof nextRun !== "number" || !Number.isFinite(nextRun)) {
job.state.nextRunAtMs = computeJobNextRunAtMs(job, now);
}
}
await persist(state);