Skip to content

fix: recompute all cron next-run times after job update - #15905

Merged
Takhoffman merged 3 commits into
openclaw:mainfrom
echoVic:fix/15750-cron-rearm-after-update
Feb 14, 2026
Merged

Takhoffman merged 3 commits into
openclaw:mainfrom
echoVic:fix/15750-cron-rearm-after-update

Conversation

@echoVic

@echoVic echoVic commented Feb 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #15750

Problem

After updating a cron job's non-schedule properties (e.g., delivery target), the scheduler's nextWakeAtMs did not recalculate properly. ALL cron jobs could stop executing.

The update() path only recomputed nextRunAtMs for the patched job and only when schedule or enabled changed. Non-schedule patches (e.g., delivery target, payload message) left the scheduler with stale timing state.

Fix

Added recomputeNextRuns(state) call after every job mutation in the update() path, mirroring what add() already does. This ensures all jobs have consistent nextRunAtMs values regardless of which fields were patched.

Changes

  • src/cron/service/ops.ts: Call recomputeNextRuns(state) after applying patch and before persist()/armTimer()

Greptile Overview

Greptile Summary

Added defensive recomputeNextRuns(state) call in the update() path after any job mutation to ensure all cron jobs maintain consistent nextRunAtMs values, mirroring the existing pattern in add(). This prevents potential scheduler breakage when non-schedule properties (e.g., delivery target, payload) are updated without triggering the conditional recomputation logic that only ran for schedule/enabled changes.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a focused defensive fix that adds consistency to the cron scheduler by ensuring all jobs recompute their next-run times after updates, matching the existing pattern used in the add() path. The fix includes clear documentation explaining the rationale and edge cases it addresses.
  • No files require special attention

Last reviewed commit: e13bdd8

echoVic and others added 3 commits February 14, 2026 12:35
The update path only recomputed nextRunAtMs for the patched job and only
when schedule or enabled changed. Non-schedule patches (e.g. delivery
target) could leave the scheduler with stale timing state, causing jobs
to stop executing entirely.

Now mirrors the add() path by calling recomputeNextRuns(state) after
every mutation, ensuring all jobs have consistent nextRunAtMs values.
@Takhoffman
Takhoffman force-pushed the fix/15750-cron-rearm-after-update branch from 0d151a7 to a826fe4 Compare February 14, 2026 18:36
@Takhoffman
Takhoffman merged commit 80407cb into openclaw:main Feb 14, 2026
9 checks passed
@Takhoffman

Copy link
Copy Markdown
Contributor

PR #15905 - fix: recompute all cron next-run times after job update (#15905)

Merged via squash.

  • Merge commit: 80407cb
  • Verified: pnpm check; pnpm vitest src/cron/service.issue-regressions.test.ts src/cron/service.issue-13992-regression.test.ts
  • Changes made:
    CHANGELOG.md
    src/cron/service.issue-regressions.test.ts
    src/cron/service/ops.ts
  • Changelog: CHANGELOG.md updated=true required=true opt_out=false

Thanks @echoVic!

@Takhoffman

Takhoffman commented Feb 14, 2026 •

Copy link
Copy Markdown
Contributor

Why these changes were made:

  • The original PR fixed issue Cron scheduler stops executing jobs after job update #15750 by recomputing next-run times after cron update, but doing a global recompute in update() can silently advance unrelated due jobs.
  • This landed version keeps the issue fix while preserving scheduler safety: it repairs only the updated job when nextRunAtMs is missing/corrupt, avoids load-time/global recompute in update(), and adds regression tests to prevent unrelated due-job advancement.

@echoVic

echoVic commented Feb 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the refinement! The per-job repair approach makes much more sense — I hadn't considered that a global recompute could silently advance unrelated due jobs. Appreciate the detailed explanation and the regression tests. 🙏

akoscz pushed a commit to akoscz/openclaw that referenced this pull request Feb 15, 2026
…) thanks @echoVic

Verified:
- pnpm check
- pnpm vitest src/cron/service.issue-regressions.test.ts src/cron/service.issue-13992-regression.test.ts

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
GwonHyeok pushed a commit to learners-superpumped/openclaw that referenced this pull request Feb 15, 2026
…) thanks @echoVic

Verified:
- pnpm check
- pnpm vitest src/cron/service.issue-regressions.test.ts src/cron/service.issue-13992-regression.test.ts

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
vincentkoc pushed a commit to vincentkoc/openclaw that referenced this pull request Feb 15, 2026
…) thanks @echoVic

Verified:
- pnpm check
- pnpm vitest src/cron/service.issue-regressions.test.ts src/cron/service.issue-13992-regression.test.ts

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…) thanks @echoVic

Verified:
- pnpm check
- pnpm vitest src/cron/service.issue-regressions.test.ts src/cron/service.issue-13992-regression.test.ts

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…) thanks @echoVic

Verified:
- pnpm check
- pnpm vitest src/cron/service.issue-regressions.test.ts src/cron/service.issue-13992-regression.test.ts

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…) thanks @echoVic

Verified:
- pnpm check
- pnpm vitest src/cron/service.issue-regressions.test.ts src/cron/service.issue-13992-regression.test.ts

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…) thanks @echoVic

Verified:
- pnpm check
- pnpm vitest src/cron/service.issue-regressions.test.ts src/cron/service.issue-13992-regression.test.ts

Co-authored-by: echoVic <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants