Skip to content

Fix cron scheduler: recompute nextRunAtMs in status/list (#11192)#11253

Closed
zhangzhefang-github wants to merge 2 commits intoopenclaw:mainfrom
zhangzhefang-github:fix/cron-scheduler-nextwakeatms-11192
Closed

Fix cron scheduler: recompute nextRunAtMs in status/list (#11192)#11253
zhangzhefang-github wants to merge 2 commits intoopenclaw:mainfrom
zhangzhefang-github:fix/cron-scheduler-nextwakeatms-11192

Conversation

@zhangzhefang-github
Copy link

@zhangzhefang-github zhangzhefang-github commented Feb 7, 2026

Fix: Cron scheduler nextWakeAtMs stuck at null (#11192)

Problem

Cron scheduler was not computing nextRunAtMs when calling status() or list() without first calling start(). This caused:

  • nextWakeAtMs: null in status output
  • Empty array returned by cron list
  • Jobs not firing

Solution

Added recomputeNextRuns() call in both status() and list() functions to ensure nextRunAtMs is always computed before returning results.

Testing

  • ✅ All existing cron tests pass (33 test files, 192 tests)
  • ✅ Linter passes with 0 errors, 0 warnings
  • ✅ Fix handles edge cases (enabled: false, missing state, etc.)

AI-Assisted

This PR was created with AI assistance (Claude). The fix has been reviewed and tested.

Related Issues

Fixes #11192
May also help with: #10955, #11059, #11013

Greptile Overview

Greptile Summary

This change updates the cron service read operations (status() and list()) to call recomputeNextRuns(state) after loading the store. This ensures nextRunAtMs (and derived nextWakeAtMs) is populated even if the scheduler hasn’t been started yet, preventing nextWakeAtMs: null and empty/unsorted cron list outputs when jobs exist but haven’t had their next run computed.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The diff is small and localized: it only adds a recomputation call under an existing lock after the store is loaded. The recomputation function is already used in normal startup paths, and it deterministically derives nextRunAtMs from current time and job schedules. No API shape changes, no persistence changes, and no new dependencies were introduced.
  • No files require special attention

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

@tyler6204
Copy link
Member

Superseded by #11641 (merge commit: 8fae55e). Closing to reduce duplicate PR noise. Please open a new PR only if there is additional scope beyond this fix.

@tyler6204 tyler6204 closed this Feb 8, 2026
SutanuNandigrami pushed a commit to SutanuNandigrami/openclaw that referenced this pull request Feb 8, 2026
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 scheduler: nextWakeAtMs stuck at null, jobs not loading despite being in jobs.json

2 participants

Comments