EveryDocumentation 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.
Step.make run function receives a second argument — a StepContext — that provides everything the step needs to interact with its environment and introspect its own execution. StepContext extends Cloudflare’s native WorkflowStepContext, so the fields you already know from vanilla Cloudflare Workflows are all present, augmented by Sideffect’s typed env and workflowStep properties.
The StepContext Interface
ctx.env — Worker Bindings
ctx.env is typed from the global Cloudflare.Env interface, giving you full TypeScript autocompletion for every binding in your Worker — R2 buckets, KV namespaces, AI, Durable Objects, Queues, and more.
ctx.env typing comes from the global Cloudflare.Env interface, which is
generated by running wrangler types in your project. If you use Sideffect’s
Vite adapter, it also emits a sideffect-env.d.ts file that augments
Cloudflare.Env with the workflow binding types it generates. You never need
to write these type declarations by hand.ctx.attempt — Retry Attempt Count
ctx.attempt is a 1-based integer that tells you how many times Cloudflare has tried to execute this step in the current workflow run. On the first execution it is 1; on the first retry it is 2, and so on. This is useful for logging, skipping expensive setup on retries, or making decisions about fallback behaviour.
ctx.step.name — Step Name
ctx.step.name is the human-readable name you passed as the first argument to Step.make. It matches the name Cloudflare records in its Workflow execution history.
ctx.config — Resolved Step Configuration
ctx.config is the resolved WorkflowStepConfig for the current step invocation. It includes the timeout, retries, and sensitive values that were passed to step.do() in the workflow (or Cloudflare’s defaults if none were provided).
ctx.workflowStep — Native Step API
ctx.workflowStep exposes the underlying NativeWorkflowStep object for cases where you need direct access to Cloudflare’s step primitives from within a step’s run function. In most cases you will not need this — use the SideffectStep façade in your workflow’s run function instead.
Workbench Example — readStepContext
The following step (from the Sideffect workbench) reads all three context properties and returns them as part of its result, demonstrating how each field is accessed:
step.do options:
readStepContext, ctx.config.timeout will reflect the "5 minutes" value that was passed through.
StepContext Property Reference
| Property | Type | Description |
|---|---|---|
ctx.env | Env | Typed Worker environment bindings (R2, KV, AI, Durable Objects, etc.). |
ctx.ctx | unknown | Worker execution context from the WorkflowEntrypoint instance. |
ctx.attempt | number | Current retry attempt, 1-based. 1 on first execution, 2 on first retry. |
ctx.step.name | string | The name string passed to Step.make. |
ctx.config | WorkflowStepConfig | Resolved step configuration (timeout, retries, sensitive). |
ctx.workflowStep | NativeWorkflowStep | Raw Cloudflare WorkflowStep API for advanced native operations. |
Steps
Define reusable, schema-validated workflow activities.
Workflows
Compose steps into full workflow pipelines.
Rollback
Attach compensation handlers to steps with Rollback.with().
Error Handling
Throw NonRetryableError to stop retries immediately.