Skip to content

fix(cron): stop recurring jobs from re-firing every poll - #65

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-967a
Draft

fix(cron): stop recurring jobs from re-firing every poll#65
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-967a

Conversation

@cursor

@cursor cursor Bot commented Aug 11, 2026

Copy link
Copy Markdown

Bug and impact

Recurring cron: schedules re-delivered the same job every main-loop poll (~1s) for the rest of the matching minute. When the following match was more than 8 days away (e.g. monthly 0 0 1 * *), next_run was never advanced and the job fired on every poll indefinitely — duplicate agent runs and runaway provider usage.

Root cause

cron_next_from_expr() started searching at now and returned the current matching minute. After cron_poll() wrote that value back as next_run, next_run <= now stayed true on the next poll. The 8-day search window also made monthly/yearly advances fail silently, leaving a still-due next_run.

Fix

  • Start cron expression search at the next minute boundary (strictly after now).
  • Expand the search window to one leap year.
  • If next_run still cannot be computed after a fire, push it one year forward so the job cannot tight-loop.

Validation

  • make test_cron && ./build/test_cron — all tests passed, including new coverage for same-minute skip, monthly >8 days, and poll advance + no immediate re-fire.

Distinct from #57 (defer DB commit until delivery succeeds).

Open in Web View Automation 

cron_next_from_expr returned the current matching minute, so after
cron_poll updated next_run the job stayed due and re-fired every poll
until the minute rolled — or forever when the next match was outside
the 8-day search window. Start from the next minute and search up to
a year; fail closed if next_run still cannot be computed.

Co-authored-by: esadrianno <[email protected]>
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.

1 participant