Add sleep workflow node backed by durable step.sleep - #1
Open
goroggabriel wants to merge 1 commit into
Open
Conversation
Adds a logic-category sleep node so workflows can pause for a fixed duration (e.g. the L0 alert triage 5 minute wait) without cron/KV workarounds. The compiled workflow calls Cloudflare Workflows step.sleep directly, mirroring how user-approval uses step.waitForEvent, so no runtime kernel ABI change or manifest migration is needed. Includes shared duration validation, builder inspector config, and nodes/compiler tests.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 0417b92. Configure here.
| return Number.isInteger(value) && value > 0 | ||
| } | ||
| return typeof value === "string" && WORKFLOW_SLEEP_DURATION_PATTERN.test(value) | ||
| } |
There was a problem hiding this comment.
Sleep duration exceeds platform limit
Medium Severity
isValidWorkflowSleepDuration accepts any positive integer milliseconds or unit label, including values above Cloudflare Workflows' step.sleep maximum of 365 days (for example 2 years, 53 weeks, or very large millisecond counts). Those options pass draft validation and compile, then fail when the durable sleep runs.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 0417b92. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
step.sleep(nodeId + ":sleep", duration)directly, mirroring howuser-approvalcallsstep.waitForEvent. The workflow consumes no compute while sleeping.CURRENT_WORKFLOW_RUNTIME_ABI_VERSIONstays at 2 and the kernel source fingerprint is unchanged. No manifest migration is needed either (new node type only, no shape change to existing manifests).Changes
packages/shared/src/workflow-nodes/definitions.ts:sleepnode type, inline executor, catalog entry (valuein →valueout pass-through, default duration5 minutes),timericon,sleep-durationoption validation rule.packages/shared/src/workflow-nodes.ts: duration validation accepting positive integer milliseconds or Cloudflare duration labels (30 seconds,5 minutes,1 day, ...).packages/api/src/server/background/workflows/compiler.ts:runSleepNodein the generated runtime + run-loop branch; invalid durations fall back to the default instead of failing mid-run.apps/web: inspector Duration field and Timer icon for the builder.tests/workflows/nodes.test.ts, durable sleep + pass-through + fallback intests/workflows/compiler.test.ts.Test plan
vitest run tests/workflows— 17 files, 147 tests passingnub run typecheck— cleannub run lint— no errorsnub run format— cleanMade with Cursor