Start here
Life of a request
Follow the ordinary static-workflow start path, then the deliveries that turn the stored intent into completed work.
Both implementations run the same core SDK. The main difference is what answers core’s storage and queue calls. This walkthrough separates accepting a run from finishing it.
Our World: accepting the run
- App → SDK
The route calls start()
The example validates the request and resolves a generated workflow ID. Direct SDK callers can skip the HTTP layer. Core resolves the World, target deployment and capabilities, then mints the run ID.
- SDK in the calling Worker
Prepare arguments and execution policy
Core records the engine and execution context. If encryption is enabled, it obtains key material and encrypts serialized values. Cross-deployment starts may probe the target first.
- SDK → store and dispatch
Persist creation and publish concurrently
Core launches the creation event and start publication in parallel. Publication passes through the store’s dispatch code; these are not simply two isolated RPC calls. The start message carries enough creation data for recovery.
- Store → R2 / SQLite → queue shard
Commit state and durable intent
Large payloads reach R2 before the referencing event. The store commits event, materialized state and outbox debt in a transaction. Dispatch first touches the shared workflow runner from the store, then hands the message to a queue shard.
- SDK → app → caller
Return a handle, not the result
The example returns
202and a run ID. Core examines both start outcomes. A retryable creation failure after successful queue admission can be recovered by the consumer. Conversely, a thrown start error does not prove nothing was persisted.
Our World: delivering and running
- Queue alarm → workflow runner
Start a durable delivery
The queue claims work on its replay lane. Run deliveries serialize per run, not across all runs on the shard. Alarm-created runner stubs prevent enqueue/replay cycles from continually extending the original subrequest chain.
- Runner → consumer → executor
Select the release
The consumer maps the recorded deployment ID through
EXECUTOR_ROUTESand calls its script in the dispatch namespace. Without WFP, it executes locally. A fresh request and SDK route do not imply a fresh Workers isolate. - SDK ↔ store / run streams
Reconstruct the workflow
Core records or reconstructs the running state, reads event pages and restores a usable QuickJS snapshot if present. Workflow decisions run inside the VM. External I/O belongs in step functions outside that VM.
- Executor → steps / queue shards
Execute inline or dispatch
Some steps run inline. Other steps are queued by key across shards and handled through step runners. Concurrent step creations and publishes gather into request-scoped batches, capped at 500 items and two calls in flight.
- Step → store → replay lane
Record the result and continue
The step writes started and completed or failed events. A continuation wakes the run. Eligible pure wakes coalesce behind a successful replay, reducing redundant work without discarding distinct inputs.
- SDK → store → indexes
Suspend or finish
A hook or sleep persists a waiting condition rather than holding an HTTP request open. On completion, the output and terminal state persist. Index pushes make the final state visible to cross-run listings, subject to eventual consistency.
Vercel: the corresponding path
- App Function → SDK
Resolve deployment, region and encryption
The adapter supplies deployment identity and a region-tagged run ID. Core serializes the arguments and prepares encryption. Deployment resolution and cross-deployment probes happen when needed.
- Function → Workflow API + Vercel Queues
Store creation and send the start
Core concurrently sends
run_createdto the managed Workflow API and publishes to the workflow’s regional topic. Queue options identify the target deployment. The same resilient-start rules apply. - Vercel Queues → flow Function
Deliver the message
The queue handler retrieves and leases a platform-delivered message. The combined SDK route handles workflow and queued-step messages; not every step requires its own Function invocation.
- Core ↔ managed Workflow API
Execute and record
The default engine is native Node. QuickJS is available as an opt-in. Event writes can use a per-run WebSocket channel; batch writes and listings remain HTTP. Events use binary frames with CBOR metadata and opaque payload bytes.
- Core → queue → Function
Continue until completion
Core queues continuations as needed and uses recorded step outcomes on replay. Spec 9 adds a per-run concurrency key. Streams and snapshots go through the managed API, whose backend internals are not established by the public client source.
What a response does and does not guarantee
| Observation | Meaning |
|---|---|
| 202 from the example | The start path returned a handle. It does not mean workflow steps completed. |
| Step completed event | The result is durable. An external side effect before that event may have happened more than once. |
| Retryable 503 | An infrastructure operation failed transiently. Use an application-level idempotency strategy when retrying starts; do not blindly assume the first attempt created nothing. |
| Listed as running | A projected list row can lag the run’s authoritative state. |
Sources and implementation
- src/routes/runs.ts
- packages/world-cloudflare/src/store/dispatch.ts
- packages/world-cloudflare/src/queue/consumer.ts
- Vercel: packages/core/src/runtime/start.ts
- Vercel: packages/world-vercel/src/queue.ts
Repository links may require access. Vercel links point to public source or published documentation. Logical API names do not establish backend internals.