A step in Sideffect is a named, self-contained unit of work that can be reused across multiple workflows. Each step carries its own Effect Schema for both its input (payload) and its output (result), ensuring that data passing in and out of every Cloudflare Workflow step is validated at runtime. Defining steps separately from workflows keeps your business logic composable, testable, and easy to share across workflow pipelines.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.
Defining a Step with Step.make
Step.make accepts a human-readable name (used as the Cloudflare step name for checkpointing) and an options object with three required fields:
| Option | Type | Description |
|---|---|---|
payload | Schema.Schema<Payload> | Decoded before run executes. Validation failures become non-retryable errors. |
result | Schema.Schema<Result> | Decoded before the result is returned from step.do(). Validation failures also become non-retryable errors. |
run | (payload: Payload, ctx: StepContext) => MaybeEffect<Result> | The step implementation. May return a direct value, a Promise, or an Effect.Effect. |
Example Steps
Synchronous step — addNumbers
The simplest steps return a direct value with no async work needed.
Async step — multiplyNumber
Steps that call external services or perform I/O return a Promise.
Effect step — effectUppercase
When you prefer Effect’s structured model, run can return an Effect.Effect.
Payload Schema Validation
Beforerun is called, Sideffect decodes the incoming payload with Schema.decodeUnknownSync. If decoding fails, the step throws a NonRetryableError with the message:
Result Schema Validation
Afterrun returns, Sideffect decodes the result with the result schema before returning it to the calling workflow. If the decoded value does not match the schema, a NonRetryableError is thrown:
Executing a Step from a Workflow with step.do
Inside a workflow’s run function, use the step.do() method on the SideffectStep façade to execute a step:
options maps directly to Cloudflare’s WorkflowStepConfig:
Example — step with timeout configuration
Example — reading StepOptions from the workbench
The workbench step-context workflow passes a timeout directly:
Reusing Steps Across Workflows
Because aStepDefinition is just a plain object, the same step can be imported into multiple workflow files:
Workflows
Compose steps into full workflow pipelines.
Rollback
Attach compensation handlers to steps with Rollback.with().
Step Context
Access env bindings, retry counts, and step metadata inside a step.
Error Handling
Throw NonRetryableError to stop retries immediately.