Workflows - Additional step context and ReadableStream support now available in Workflows step.do()
Key Points
- Extended step context: name, count, config, attempt
- step.do() can return ReadableStream for large outputs
- Streamed outputs still count toward workflow storage limit
Summary
Workflows' step.do() callbacks now receive an extended context object (including step.name, step.count, config, and attempt) and can return ReadableStream results to handle much larger outputs. Non-stream outputs remain limited to 1 MiB; streamed outputs support larger payloads but still count toward the Workflow instance storage limit.
Key Points
- New context object passed to
step.do(stepName, callback)includes:step.name: the name passed to the stepstep.count: how many times that step name has been invoked in this instance (1-indexed)config: resolved step configuration (retries,timeoutwith defaults applied)attempt: current attempt number
step.do()can return aReadableStreamdirectly to stream large outputs beyond the 1 MiB non-stream limit.- Streamed outputs are still part of the Workflow instance storage limit; plan storage usage accordingly.
- TypeScript types are provided (e.g.
ResolvedStepConfig,WorkflowStepContext) for safer typing.
Example
Inline example calling a bucket and returning a stream:
const largePayload = await step.do("fetch-large-file", async () => (await env.MY_BUCKET.get("large-file.bin")).body);
Recommended actions
- Use
step.countto distinguish repeated step invocations in loops. - Return
ReadableStreamfrom steps when handling large files to avoid the 1 MiB non-stream limit. - Monitor workflow storage usage since streams still consume instance storage.