Skip to content

fix(core): preserve long workflow wait durations - #1558

Open
1828703450qqcom-ux wants to merge 2 commits into
VoltAgent:mainfrom
1828703450qqcom-ux:fix/workflow-long-timers
Open

1828703450qqcom-ux wants to merge 2 commits into
VoltAgent:mainfrom
1828703450qqcom-ux:fix/workflow-long-timers

Conversation

@1828703450qqcom-ux

@1828703450qqcom-ux 1828703450qqcom-ux commented Nov 21, 2026 •

Copy link
Copy Markdown

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.

Written for commit 78378c8. Summary will update on new commits.

View guided diff

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.

@changeset-bot

changeset-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 78378c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

waitWithSignal now handles durations longer than the Node.js timer limit by scheduling consecutive timer intervals. Tests check completion after the requested duration and rejection when cancellation or suspension occurs during a long wait.

Changes: Workflow timer waits

Layer / File(s) Summary
Segment long waits and validate completion and abort behavior
packages/core/src/workflow/steps/signal.ts, packages/core/src/workflow/steps/signal.spec.ts, .changeset/calm-workflow-timers.md
waitWithSignal caps each timer interval and subtracts completed intervals until the remaining duration fits. Tests check that a long wait completes after its full duration and that cancellation or suspension rejects with the corresponding workflow error and leaves no timers pending. The changeset declares a patch release for @voltagent/core.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 78378

Workflow sleeps and retry delays longer than the Node.js timer limit now wait for their full duration instead of firing early, and cancellation or suspension still interrupts them. Tests cover both behaviors. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(core): preserve long workflow wait durations" matches the main change. The changeset and the signal.ts edit split waits longer than the Node.js timer limit into consecutive timer waits,…
Description check Passed The description follows the repository template. It completes the checklist items for tests, changeset, and commit message, and it has sections for current behavior, new behavior, and reviewer notes. …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(core): preserve long workflow wait durations" matches the main change. The changeset and the signal.ts edit split waits longer than the Node.js timer limit into consecutive timer waits, so the requested duration is kept. The title is specific, follows the conventional commit form, and names the affected package.

Full details: Description check

Explanation

The description follows the repository template. It completes the checklist items for tests, changeset, and commit message, and it has sections for current behavior, new behavior, and reviewer notes. It explains the root cause: setTimeout reduces delays above 2_147_483_647 ms to 1 ms. It also lists the tests and the validation that ran. The template's "fixes (issue)" line has no linked issue number, and the "Docs have been added / updated" item is not checked and has no explanation. These are minor gaps.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 73ea73e6-acb5-49e1-b1cf-510d4d1ad59a
Commits

Reviewing files that changed from the base of the PR and between d7fbb1b and 78378c8.

Files selected for processing: 2

  • .changeset/calm-workflow-timers.md
  • packages/core/src/workflow/steps/signal.spec.ts
Files skipped from review as they are similar to previous changes: 1

  • .changeset/calm-workflow-timers.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

Comment thread .changeset/calm-workflow-timers.md Resolved

This branch has not been deployed

No deployments
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