Repository navigation
feat(void): add Cloudflare Workflows through a workflows/ convention - #918
Draft
isakgustavsen wants to merge 2 commits into
Draft
isakgustavsen wants to merge 2 commits into
isakgustavsen wants to merge 2 commits into
Conversation
Each default-exported defineWorkflow() or defineWorkflowEntrypoint() module in workflows/ becomes a Cloudflare Workflow with a WORKFLOW_<NAME> binding and <Name>Workflow class, started from routes with Definition.create(), createBatch() and get(). Params can be validated with a Standard Schema. Discovery follows queues/: subdirectories are joined with '-' and paths with a '_'-prefixed segment are ignored, so step helpers can live beside the workflows. Deploys to Cloudflare name each Workflow <worker>-<resource>, since Workflow names are account-scoped, and verify the emitted set before upload. Void platform deploys, framework mode and Node targets reject workflows/ for now. The generated Worker entry now imports convention modules through their namespace and fails startup with a named error when a module does not default-export a definition; this also covers durable-objects/. Closes voidzero-dev#779 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resource imports used only inside workflows/, including _-prefixed step helpers and nested folders, now count toward binding inference, as they already do for durable-objects/. Apps with a sourceDir scan workflows/ too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Closes #779
Adds Cloudflare Workflows to native Void apps, defined like Durable State and discovered like queues.
What it adds
void/workflows(server-only):defineWorkflow({ name?, params?, run })anddefineWorkflowEntrypoint({ name?, class })for nativeWorkflowEntrypointclasses, mirroringdefineDurableState/defineDurableObject. The returned definition hascreate(),createBatch()andget(), each also accepting an explicitWorkflowbinding first, likeget(namespace, name)on Durable Objects.paramsvalidates beforecreate()/createBatch().runreceives the parsed type, and invalid params throwWorkflowParamsErrorwith{ message, path }issues.workflows/send-welcome.tsbecomes theWORKFLOW_SEND_WELCOMEbinding (prefix, likeQUEUE_*) and theSendWelcomeWorkflowclass. Subdirectories join with-(order/notifications.ts→order-notifications), and paths with a_-prefixed segment are ignored, as inqueues/. Optional staticnamepins identity, andvoid inforeports it.<worker>-<resource>, since Workflow names are account-scoped. The deploy passes the Worker name to the build, and the emittedworkflowsset is pinned before the build and verified before upload. An authoredcloudflare.workflowsentry with the same binding and class keeps its name. Workflows are on Workers Free.workflows/with an actionable error for now.workflows/(including_helpers and subfolders), so a Workflow that is the only user ofvoid/db,void/kvand similar still gets the binding.durable-objects/): the generated Worker entry imports convention modules through their namespace and fails startup with a named error when a file does not default-export a definition.info, skill index and packageAGENTS.md.Testing
_ignore, collisions), config merge, runtime API and types, entry compilation,void info.vp builddeploy-config merge.vp checkpasses formatting and lint. Its only errors are tsconfigs that unbuilt playgrounds haven't generated, and none are in changed files.vp run test: 2,766 passed. The 14 failures are platform admin browser tests that need Playwright's Chromium, which isn't installed locally. This PR doesn't touchplatform/.Follow-ups
runshould also validate params for instances started outside Void (dashboard,wrangler workflows trigger, raw binding).🤖 Generated with Claude Code