-
-
Notifications
You must be signed in to change notification settings - Fork 69.2k
Cron: 'at' jobs don't fire after being rescheduled #19676
Copy link
Copy link
Closed
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Bug Description
When a kind: 'at' scheduled job is updated with a new atMs timestamp, it doesn't fire if the job previously ran successfully.
Root Cause
In src/cron/service/jobs.ts, the computeJobNextRunAtMs function has this logic:
if (job.schedule.kind === 'at') {
// One-shot jobs stay due until they successfully finish.
if (job.state.lastStatus === 'ok' && job.state.lastRunAtMs)
return undefined;
return job.schedule.atMs;
}When rescheduling an 'at' job to a new time, the lastStatus remains 'ok' from the previous run, so the function returns undefined instead of the new schedule.atMs.
Reproduction
- Create an 'at' job scheduled for 5 minutes from now
- Let it run successfully (
lastStatus: 'ok') - Update the job with a new
atMs1 hour in the future - The job never fires because
nextRunAtMsisundefined
Expected Behavior
When updating an 'at' job with a new atMs that is greater than lastRunAtMs, the job should be scheduled to run at the new time.
Suggested Fix
Change the condition to also check if the new scheduled time is after the last run:
if (job.schedule.kind === 'at') {
if (job.state.lastStatus === 'ok' &&
job.state.lastRunAtMs &&
job.schedule.atMs <= job.state.lastRunAtMs)
return undefined;
return job.schedule.atMs;
}Environment
- Clawdbot version: (installed via npm)
- Node: v22.22.0
- OS: macOS (Darwin arm64)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Give feedbackNo fields configured for issues without a type.