Description
cron.start() crashes with TypeError: Cannot read properties of undefined (reading 'runningAtMs') when any job in jobs.json has a null or missing state field.
This prevents all cron jobs from running — not just the one with the missing state.
Version
OpenClaw 2026.4.1 (da64a97)
Steps to reproduce
- Add a job to
~/.openclaw/cron/jobs.json without a state field (or with "state": null)
- Restart the gateway
- Observe in logs:
[cron] failed to start: TypeError: Cannot read properties of undefined (reading 'runningAtMs')
This can happen when jobs are added programmatically or restored from a backup/reference file that doesn't include runtime state.
Root cause
In cron-cli-BBHRXUsj.js:184, the formatStatus function accesses job.state.runningAtMs without null-checking job.state:
const formatStatus = (job) => {
if (!job.enabled) return "disabled";
if (job.state.runningAtMs) return "running"; // crashes here
return job.state.lastStatus ?? "idle";
};
The cron scheduler itself handles this case correctly (line 5786-5787 of gateway-cli):
if (!job.state) {
job.state = {};
But formatStatus is called during cron.start() before the scheduler gets a chance to initialize the state, so the entire cron system fails to start.
Suggested fix
const formatStatus = (job) => {
if (!job.enabled) return "disabled";
if (job.state?.runningAtMs) return "running";
return job.state?.lastStatus ?? "idle";
};
Workaround
Ensure all jobs have at least "state": {} before the gateway starts.
Impact
When this bug triggers, all cron jobs stop running (not just the affected one), since the entire cron service fails to start. No scheduled tasks, no deliveries, no monitoring — silent failure with only a single log line.
Description
cron.start()crashes withTypeError: Cannot read properties of undefined (reading 'runningAtMs')when any job injobs.jsonhas anullor missingstatefield.This prevents all cron jobs from running — not just the one with the missing state.
Version
OpenClaw 2026.4.1 (da64a97)
Steps to reproduce
~/.openclaw/cron/jobs.jsonwithout astatefield (or with"state": null)[cron] failed to start: TypeError: Cannot read properties of undefined (reading 'runningAtMs')This can happen when jobs are added programmatically or restored from a backup/reference file that doesn't include runtime state.
Root cause
In
cron-cli-BBHRXUsj.js:184, theformatStatusfunction accessesjob.state.runningAtMswithout null-checkingjob.state:The cron scheduler itself handles this case correctly (line 5786-5787 of
gateway-cli):But
formatStatusis called duringcron.start()before the scheduler gets a chance to initialize the state, so the entire cron system fails to start.Suggested fix
Workaround
Ensure all jobs have at least
"state": {}before the gateway starts.Impact
When this bug triggers, all cron jobs stop running (not just the affected one), since the entire cron service fails to start. No scheduled tasks, no deliveries, no monitoring — silent failure with only a single log line.