Skip to content

fix(cron): honor equal jitter bounds and reject negative MinSec#736

Merged
dennisonbertram merged 1 commit into
mainfrom
fix-jitter-equal-bounds
Jul 16, 2026
Merged

fix(cron): honor equal jitter bounds and reject negative MinSec#736
dennisonbertram merged 1 commit into
mainfrom
fix-jitter-equal-bounds

Conversation

@dennisonbertram

Copy link
Copy Markdown
Owner

Problem

computeJitter's guard was MinSec >= MaxSec → return 0. Two edge-case bugs:

  • MinSec == MaxSec (a fixed offset) returned 0 — no jitter — instead of that exact offset.
  • A negative MinSec slipped through (since min < max), so raw could land in e.g. [-60, 300] — a negative jitter subtracted from the fire time.

Fix

Guard on MinSec > MaxSec (zero) and MinSec < 0 (invalid → zero) instead of >=. Now min == max yields exactly MinSec seconds (verified: span=0, IntN(1)=0, raw=MinSec), and negative min is rejected. Tests split into EqualBounds and MinGreaterThanMax; cron package green under -race.

🤖 Generated with Claude Code

computeJitter's guard treated MinSec == MaxSec as "no jitter" (returned 0), so a
job configured with a fixed offset (min == max) got no jitter at all instead of
that exact offset. It also let a negative MinSec through, which could produce a
negative jitter duration subtracted from the fire time.

Guard on MinSec > MaxSec (still zero) and MinSec < 0 (invalid, zero) instead of
MinSec >= MaxSec. Now min == max yields exactly MinSec seconds, and negative
MinSec is rejected. Tests split accordingly (EqualBounds, MinGreaterThanMax).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0182aJaeQgukK1vkNjy95wt6
@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@dennisonbertram
dennisonbertram merged commit 05ae342 into main Jul 16, 2026
2 checks passed
@dennisonbertram
dennisonbertram deleted the fix-jitter-equal-bounds branch July 16, 2026 02:21
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