fix(cron): migrate legacy schedule cron fields on load (#28889)

Backfill legacy jobs that still use schedule.cron and jobId so upgraded instances keep firing existing cron schedules instead of failing silently.

Closes #28861
This commit is contained in:
Sid
2026-03-01 20:53:39 +08:00
committed by GitHub
parent d509a81a12
commit 504c1f3607
6 changed files with 147 additions and 6 deletions

View File

@@ -25,6 +25,19 @@ describe("cron schedule", () => {
).toThrow("invalid cron schedule: expr is required");
});
it("supports legacy cron field when expr is missing", () => {
const nowMs = Date.parse("2025-12-13T00:00:00.000Z");
const next = computeNextRunAtMs(
{
kind: "cron",
cron: "0 9 * * 3",
tz: "America/Los_Angeles",
} as unknown as { kind: "cron"; expr: string; tz?: string },
nowMs,
);
expect(next).toBe(Date.parse("2025-12-17T17:00:00.000Z"));
});
it("computes next run for every schedule", () => {
const anchor = Date.parse("2025-12-13T00:00:00.000Z");
const now = anchor + 10_000;