-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
Feature: Cron job catch-up for missed runs after gateway restart #10067
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
When the gateway restarts after a cron job's scheduled time has passed, the job is skipped and waits for the next cycle. This causes missed runs if the gateway happens to be down during a job's scheduled time.
Example scenario:
- Job scheduled for 08:00 daily
- Gateway restarts at 09:35 (e.g., after an update or system wake)
- The 08:00 job is skipped, nextRunAtMs jumps to tomorrow
- User misses their daily digest/report
Proposed Solution
Add an optional catchUp flag to cron schedules. When enabled:
- On gateway startup, compare
lastRunAtMswith the expected run time - If the job was supposed to run since the last execution but didn't, trigger it immediately
- Then resume normal scheduling
Suggested Config
{
"schedule": {
"kind": "cron",
"expr": "0 8 * * *",
"tz": "Asia/Shanghai",
"catchUp": true
}
}Behavior
| Scenario | catchUp: false (current) | catchUp: true (proposed) |
|---|---|---|
| Gateway restarts after scheduled time | Skip, wait for next cycle | Run immediately, then resume |
| Gateway restarts before scheduled time | Run at scheduled time | Run at scheduled time |
| Multiple missed runs | All skipped | Run once (most recent) |
Alternatives Considered
- Heartbeat-based workaround: Check cron status in HEARTBEAT.md and manually trigger missed jobs. Works but adds complexity and token cost.
- Always catch up: Could be surprising for some use cases, hence making it opt-in.
Additional Context
This is especially important for daily digest/report jobs where missing a day means missing that day's content entirely.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Fields
Give feedbackNo fields configured for issues without a type.