-
-
Notifications
You must be signed in to change notification settings - Fork 69.2k
[Bug]: Cron scheduler cannot detect missed executions #13947
Copy link
Copy link
Closed as not planned
Labels
bugSomething isn't workingSomething isn't workingstaleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Summary
Cron scheduler has a fundamental design flaw where it cannot detect missed executions, has no execution history tracking, and returns "not-due" for manual triggers even when jobs have never run.
What went wrong?
cron:runsreturns empty array for all jobs despite 8 being configured- Manual
cron:run <jobId>returns{"ran": false, "reason": "not-due"}for jobs that have never executed - Scheduler only checks "is next run in the future?" without tracking "when did it last run?"
- No catch-up mechanism for missed executions
Steps to reproduce
- Create a cron job:
cron:addwith daily schedule - Wait 5 days without any executions
- Query run history:
cron:runs <jobId>→ returns[] - Attempt manual trigger:
cron:run <jobId>→ returns{"ok": true, "ran": false, "reason": "not-due"} - Check scheduler status:
cron:status→ showsenabled: true
Expected behavior
cron:runsshould show execution historycron:runshould have--forceoption for overdue jobs- Scheduler should detect and catch up on missed runs
- Jobs should execute according to schedule
Actual behavior
- 8 cron jobs created Feb 6, zero executions by Feb 11
- All run history queries return empty
- Manual triggers rejected with "not-due"
- No way to force execution or recover from scheduling gaps
Environment
- OpenClaw version: 2026.2.3 (e75e2b1)
- OS: Ubuntu 22.04 (Linux 6.8.0-94-generic)
- Install method: pnpm/npm
Logs
Cron job state shows only nextRunAtMs with no lastRunAtMs:
{
"id": "ff7809e6-dfa7-4c74-b4e5-4c940c8fa4d4",
"enabled": true,
"schedule": {"kind": "cron", "expr": "55 23 * * *", "tz": "America/Los_Angeles"},
"state": {"nextRunAtMs": 1770796500000}
}
cron:runs returns: {"runs": []}
cron:run returns: {"ok": true, "ran": false, "reason": "not-due"}
Proposed fix
Add execution history tracking and catch-up logic:
interface CronJobState {
lastRunAtMs: number; // Track last execution
missedRuns: number; // Detect missed executions
consecutiveFailures: number;
// ... existing fields
}
Add force parameter to cron:run for manual override of "not-due" jobs.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingstaleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Give feedbackNo fields configured for issues without a type.