Skip to content

fix: runner promise bugs that could hang scheduling or crash process#581

Merged
merencia merged 3 commits into
mainfrom
fix/runner-promise-bugs
Jun 24, 2026
Merged

fix: runner promise bugs that could hang scheduling or crash process#581
merencia merged 3 commits into
mainfrom
fix/runner-promise-bugs

Conversation

@merencia

@merencia merencia commented Jun 24, 2026

Copy link
Copy Markdown
Member

Two bugs in the Runner:

  1. runTask used new Promise(async ...). If beforeRun threw, the promise never settled. With noOverlap, this blocked all future executions permanently.

  2. The TrackedPromise tracking lastExecution was never .catch()-ed. On Node 22+ this crashes the process with unhandledRejection.

Rewrote runTask as a plain async function and added .catch() on the TrackedPromise.

merencia added 3 commits June 24, 2026 14:33
Two fixes in the Runner:

1. Replace `new Promise(async ...)` antipattern in runTask with a plain
   async function. Previously, if beforeRun threw, the promise would
   never settle, permanently blocking all future executions when
   noOverlap is enabled.

2. Add .catch() to the TrackedPromise tracking lastExecution. Errors are
   already reported via onError, but the rejection was never consumed,
   causing unhandledRejection on Node 22+ (which crashes the process by
   default).
beforeRun errors were silently swallowed by .catch(() => {}) on the
TrackedPromise. Now they are caught and routed to onError like task errors.

Also protects execute() against onError itself throwing (same class of bug
as the async executor fix), and fixes the jitter setTimeout to always
resolve its promise regardless of errors.
@merencia merencia force-pushed the fix/runner-promise-bugs branch from d65e0c1 to a7b0410 Compare June 24, 2026 17:41
@merencia merencia merged commit 0ae62be into main Jun 24, 2026
7 checks passed
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