Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eersnington/sideffect/llms.txt
Use this file to discover all available pages before exploring further.
Workflow is the entry point for defining a Cloudflare Workflow in Sideffect. It creates a typed workflow definition that you bind to an implementation and, from there, expose to the Cloudflare Workflows runtime. Import it directly from sideffect.
Workflow.make(options)
Creates a typed WorkflowDefinition. The definition holds the workflow name and payload schema but does not contain any executable logic yet — call .toLayer(run) on the returned object to attach the implementation.
The Cloudflare Workflow name. Sideffect derives the entrypoint class name and
the
env binding name from this value automatically.name value | Class name | env binding |
|---|---|---|
"image-processing" | ImageProcessing | IMAGE_PROCESSING |
"add-numbers" | AddNumbers | ADD_NUMBERS |
"billing" | Billing | BILLING |
An Effect Schema used to
decode the raw Cloudflare workflow event payload before the
run function
executes. Decode failures are automatically converted to NonRetryableError
so the workflow is not retried on invalid input.WorkflowDefinition<Payload, Env> with a toLayer() method.
WorkflowDefinition.toLayer(run)
Binds a workflow definition to its implementation. The returned WorkflowLayer is what the Vite plugin discovers, or what you pass to WorkflowEntrypoints.make() when using plain Wrangler.
The workflow implementation. Receives two arguments:
workflow: WorkflowContext<Payload, Env>— contains the decodedpayload, the full Cloudflareeventobject (with decoded payload attached),envbindings, and the Workerctx.step: SideffectStep<Env>— the Sideffect step helper (see below).
run may be an async function, a synchronous function, or an
Effect.Effect.WorkflowLayer<Payload, Result, Env> consumed by the Vite plugin or WorkflowEntrypoints.make().
SideffectStep methods
The step object passed to every run function exposes four methods that mirror Cloudflare’s native WorkflowStep API, with added type safety and schema validation.
step.do(stepDefinition, payload, options?)
Runs a typed StepDefinition through Cloudflare’s native step system. Sideffect decodes the payload with the step’s payload schema before calling run, and decodes the result with the result schema before returning it to the workflow. Schema decode failures become NonRetryableError.
A step created with
Step.make(...), optionally decorated with
Rollback.with(...)).The input value for the step. Must satisfy the step’s
payload schema.Optional Cloudflare step configuration. See
StepOptions for the full shape.Promise<Result> — the decoded step result.
step.sleep(name, duration)
Pauses workflow execution for a fixed duration. The name is shown in the Cloudflare Workflows dashboard timeline.
A human-readable label for this pause, e.g.
"wait before retry".How long to pause. Pass a Cloudflare duration string such as
"1 second",
"5 minutes", "2 hours", or a number of milliseconds.Promise<void>.
step.sleepUntil(name, timestamp)
Pauses workflow execution until a specific point in time.
A human-readable label for this pause.
A
Date object or a Unix timestamp in milliseconds.Promise<void>.
step.waitForEvent(name, options)
Suspends the workflow until an external event of the given type arrives.
A human-readable label for this wait, e.g.
"await approval".The event type to wait for. Cloudflare matches events by this string.
Optional maximum wait duration. A Cloudflare duration string such as
"24 hours" or a number of milliseconds. If the timeout elapses before the
event arrives, Cloudflare terminates the wait.Promise<WorkflowStepEvent<A>>.
Complete example
The following workflow definition is taken from the Sideffect workbench. It demonstratesWorkflow.make, toLayer, step.do, and step.sleep together.
step.sleep and step.waitForEvent:
The workflow
name is the single source of truth for Cloudflare’s internal
workflow name, the generated entrypoint class name, and the env binding.
Keep it stable across deployments — renaming a live workflow requires a
migration.