fix(core): preserve long workflow wait durations

18
7d ago
+59-2

PR Checklist

  • The commit message follows the contributor guidelines.

Bugs / Features

  • Tests for the changes have been added.
  • A patch changeset has been added.

What is the current behavior?

A workflow sleep of 30 days can continue after about 1 ms. andSleep, andSleepUntil, and workflow retry delays share a helper that passes the whole duration to setTimeout. Node.js reduces delays greater than 2_147_483_647 ms to 1 ms. Node.js timer documentation

What is the new behavior?

The helper waits in intervals that stay within the timer limit until the requested duration elapses. Cancellation and suspension can still interrupt the current interval.

Notes for reviewers

  • Both new regression tests fail on main and pass with the fix. One checks that the full delay elapses. The other checks cancellation during the second interval and confirms the timer is cleared.
  • The standard @voltagent/core Vitest workflow suite passed all 166 tests, including the six existing sleep tests and the two new regressions.
  • The core package build and typecheck passed. Biome checked the TypeScript changes, and Prettier checked the changeset.
  • Developed with OpenAI Codex assistance.

Summary by cubic

Fixes workflow sleep steps so they wait for their full requested duration instead of resolving early. Delays over 2_147_483_647 ms (~24.8 days) previously caused setTimeout to fire after ~1 ms, so a 30-day sleep would complete almost immediately.

The wait helper now chunks long durations into intervals below the timer limit while still supporting cancellation and suspension. Added regression tests for full-duration waits, and for cancellation and suspension after a chunk elapses.

Summary by CodeRabbit

  • Bug Fixes
    • Workflow sleep steps and retry delays now honor their full requested durations, including durations longer than Node.js’s timer limit.
    • Cancelling or suspending a long wait still interrupts it promptly, including while the wait is split into timer intervals.