openclaw/src/cron
fujiwara-tofu-shop b0befb5f5d
fix(cron): handle legacy atMs field in schedule when computing next run (#9932)
* fix(cron): handle legacy atMs field in schedule when computing next run

The cron scheduler only checked for `schedule.at` (string) but legacy jobs
may have `schedule.atMs` (number) from before the schema migration.

This caused nextRunAtMs to stay null because:
1. Store migration runs on load but may not persist immediately
2. Race conditions or file mtime issues can skip migration
3. computeJobNextRunAtMs/computeNextRunAtMs only checked `at`, not `atMs`

Fix: Make both functions defensive by checking `atMs` first (number),
then `atMs` (string, for edge cases), then falling back to `at` (string).

This ensures jobs fire correctly even if:
- Migration hasn't run yet
- Old data was written by a previous version
- The store was manually edited

Fixes #9930

* fix: validate numeric atMs to prevent NaN/Infinity propagation

Addresses review feedback - numeric atMs values are now validated with
Number.isFinite() && atMs > 0 before use. This prevents corrupted or
manually edited stores from causing hot timer loops via setTimeout(..., NaN).
2026-02-05 15:49:03 -08:00
..
isolated-agent fix: remove unused cron import 2026-02-05 07:56:16 +00:00
service fix(cron): handle legacy atMs field in schedule when computing next run (#9932) 2026-02-05 15:49:03 -08:00
cron-protocol-conformance.test.ts fix(cron): fix test failures and regenerate protocol files 2026-02-04 01:03:59 -08:00
delivery.ts feat(cron): enhance delivery handling and testing for isolated jobs 2026-02-04 01:03:59 -08:00
isolated-agent.delivers-response-has-heartbeat-ok-but-includes.test.ts fix: cron announce delivery path (#8540) (thanks @tyler6204) 2026-02-04 01:03:59 -08:00
isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts fix: cron announce delivery path (#8540) (thanks @tyler6204) 2026-02-04 01:03:59 -08:00
isolated-agent.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
isolated-agent.uses-last-non-empty-agent-text-as.test.ts feat(cron): enhance delivery modes and job configuration 2026-02-04 01:03:59 -08:00
normalize.test.ts feat(cron): enhance delivery handling and testing for isolated jobs 2026-02-04 01:03:59 -08:00
normalize.ts feat(cron): set default enabled state for cron jobs 2026-02-04 01:03:59 -08:00
parse.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
payload-migration.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
run-log.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
run-log.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
schedule.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
schedule.ts fix(cron): handle legacy atMs field in schedule when computing next run (#9932) 2026-02-05 15:49:03 -08:00
service.every-jobs-fire.test.ts fix(cron): prevent recomputeNextRuns from skipping due jobs in onTimer (#9823) 2026-02-05 15:43:37 -08:00
service.jobs.test.ts feat(cron): enhance legacy delivery handling in job patches 2026-02-04 01:03:59 -08:00
service.prevents-duplicate-timers.test.ts feat(cron): enhance delivery modes and job configuration 2026-02-04 01:03:59 -08:00
service.runs-one-shot-main-job-disables-it.test.ts fix: cron announce delivery path (#8540) (thanks @tyler6204) 2026-02-04 01:03:59 -08:00
service.skips-main-jobs-empty-systemevent-text.test.ts feat(cron): enhance delivery modes and job configuration 2026-02-04 01:03:59 -08:00
service.store.migration.test.ts feat(cron): enhance delivery handling and testing for isolated jobs 2026-02-04 01:03:59 -08:00
service.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
store.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
types.ts feat(cron): enhance delivery modes and job configuration 2026-02-04 01:03:59 -08:00
validate-timestamp.ts feat(cron): enhance delivery modes and job configuration 2026-02-04 01:03:59 -08:00