Skip to content

fix(scheduler): clamp watchdog timer delays and suppress only an armed timer - #648

Open
tnunamak wants to merge 1 commit into
mainfrom
fix/watchdog-timer-clamp-and-latch
Open

tnunamak wants to merge 1 commit into
mainfrom
fix/watchdog-timer-clamp-and-latch

Conversation

@tnunamak

@tnunamak tnunamak commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

No change for any valid budget. Two edge cases in the run watchdog (createAttemptWatchdog) are fixed.
Timer delays are now clamped to the 2^31 - 1 ms limit that Node's setTimeout accepts. A longer delay fires almost at once, and budget * 4 for the local-only ceiling could overflow to Infinity, which reads as "unbounded", so a huge finite budget lost its ceiling.
markProgress reported a suppression, and the caller wrote a "watchdog suppressed" spine event and progress message, even when no timer was armed: with a 0 or Infinity budget, after the watchdog fired, or after an owner cancel. It now latches only while a primary timer could still fire.
Proof: seven tests in run-executor-watchdog-limits.test.ts. Six failed on main (both clamp cases, both opt-out budgets, fire-then-boundary, cancel-then-boundary) and pass now; one control (an armed watchdog latches once) passes on both. The existing watchdog and run-history tests pass.
The non-required "mutate changed production files" job cannot sample scheduler/run-executor.ts because 12 test files import it, so it fails for any change to that file beyond a trivial one.
Assisted-by: AI

…d timer

Node fires a setTimeout longer than 2^31 - 1 ms almost at once, and budget * 4
can overflow to Infinity, which reads as unbounded. Timer delays are now
clamped, so a huge finite budget keeps a real ceiling.

markProgress latched the local-only phase and reported a suppression even when
nothing was armed: with an opt-out budget (0 or Infinity), after the watchdog
fired, or after an owner cancel. The caller then recorded a "watchdog
suppressed" event for a suppression that never happened. It now latches only
while a primary timer could still fire.

Assisted-by: AI
Signed-off-by: Tim Nunamaker <tnunamak@gmail.com>
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