fix(cron): backfill updatedAtMs in fresh-clone path

Jobs loaded from a git-cloned jobs.json (no state file, no inline
state) had updatedAtMs undefined, violating the type contract and
breaking updatedAtMs sort. Backfill from createdAtMs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Feelw00
2026-04-08 20:21:35 +09:00
committed by Gustavo Madeira Santana
parent 0ed61b31a5
commit 074fabc540

View File

@@ -143,6 +143,9 @@ export async function loadCronStore(storePath: string): Promise<CronStoreFile> {
// No state file, no inline state: fresh clone or first run.
for (const job of store.jobs) {
job.state = (job.state && typeof job.state === "object" ? job.state : {}) as never;
if (typeof job.updatedAtMs !== "number") {
job.updatedAtMs = typeof job.createdAtMs === "number" ? job.createdAtMs : Date.now();
}
}
}
// else: migration mode — no state file but jobs.json has inline state. Use as-is.