Skip to content

fix(cron): correct nextRunAtMs calculation for past times#1

Open
hly3825 wants to merge 1 commit intomainfrom
fix-cron-wrong-year-bug
Open

fix(cron): correct nextRunAtMs calculation for past times#1
hly3825 wants to merge 1 commit intomainfrom
fix-cron-wrong-year-bug

Conversation

@hly3825
Copy link
Owner

@hly3825 hly3825 commented Feb 6, 2026

Fixes openclaw#10035

Summary

When creating a cron job with a time that has already passed today, the nextRunAtMs was incorrectly calculated as one year in the past (2025 instead of 2026), causing the job to never run.

Changes

  • Modified src/cron/schedule.ts
  • Added detection for nextRunAtMs being more than 24h in the past
  • Forces recalculation from current time when this condition is detected

Testing

  • Tested with Asia/Shanghai timezone
  • Tested with jobs scheduled for 07:30 and 08:00 when created after those times
  • Verified nextRunAtMs now correctly points to the next day (2026-02-07)

Fixes openclaw#10035

When creating a cron job with a time that has already passed today,
the nextRunAtMs was incorrectly calculated as one year in the past.
This fix detects when the calculated time is more than 24 hours in
the past and forces recalculation from the current time.

Tested with Asia/Shanghai timezone jobs scheduled for 07:30 and 08:00.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cron nextRunAtMs calculated with wrong year (2025 instead of 2026) when job time has passed

1 participant