{"id":391,"date":"2026-04-21T12:00:00","date_gmt":"2026-04-21T12:00:00","guid":{"rendered":"https:\/\/wordpress.securinsight.ca\/index.php\/2026\/04\/21\/workflows-additional-step-context-and-readablestream-support-now-available-in-workflows-step-do\/"},"modified":"2026-04-21T12:00:00","modified_gmt":"2026-04-21T12:00:00","slug":"workflows-additional-step-context-and-readablestream-support-now-available-in-workflows-step-do","status":"publish","type":"post","link":"https:\/\/wordpress.securinsight.ca\/index.php\/2026\/04\/21\/workflows-additional-step-context-and-readablestream-support-now-available-in-workflows-step-do\/","title":{"rendered":"Workflows &#8211; Additional step context and ReadableStream support now available in Workflows step.do()"},"content":{"rendered":"<p><a href=\"https:\/\/developers.cloudflare.com\/workflows\/\">Workflows<\/a> now provides additional context inside <code>step.do()<\/code> callbacks and supports returning <code>ReadableStream<\/code> to handle larger step outputs.<\/p>\n<h4>Step context properties<\/h4>\n<p>The <code>step.do()<\/code> callback receives a context object with new properties <a href=\"https:\/\/developers.cloudflare.com\/changelog\/post\/2026-03-06-step-context-available\/\">alongside<\/a> <code>attempt<\/code>:<\/p>\n<ul>\n<li><strong><code>step.name<\/code><\/strong> \u2014 The name passed to <code>step.do()<\/code><\/li>\n<li><strong><code>step.count<\/code><\/strong> \u2014 How many times a step with that name has been invoked in this instance (1-indexed)\n<ul>\n<li>Useful when running the same step in a loop.<\/li>\n<\/ul>\n<\/li>\n<li><strong><code>config<\/code><\/strong> \u2014 The resolved step configuration, including <code>timeout<\/code> and <code>retries<\/code> with defaults applied<\/li>\n<\/ul>\n<div>\n<figure>\n<pre data-language=\"ts\"><code class=\"language-ts\"><div><div><span>type<\/span><span> <\/span><span>ResolvedStepConfig<\/span><span> <\/span><span>=<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>retries<\/span><span>:<\/span><span><span> <\/span><span>{<\/span><\/span><\/div><\/div><div><div><span><span>    <\/span><\/span><span>limit<\/span><span>:<\/span><span> <\/span><span>number<\/span><span>;<\/span><\/div><\/div><div><div><span><span>    <\/span><\/span><span>delay<\/span><span>:<\/span><span> <\/span><span>WorkflowDelayDuration<\/span><span> <\/span><span>|<\/span><span> <\/span><span>number<\/span><span>;<\/span><\/div><\/div><div><div><span><span>    <\/span><\/span><span>backoff<\/span><span>?:<\/span><span> <\/span><span>\"constant\"<\/span><span> <\/span><span>|<\/span><span> <\/span><span>\"linear\"<\/span><span> <\/span><span>|<\/span><span> <\/span><span>\"exponential\"<\/span><span>;<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>};<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>timeout<\/span><span>:<\/span><span> <\/span><span>WorkflowTimeoutDuration<\/span><span> <\/span><span>|<\/span><span> <\/span><span>number<\/span><span>;<\/span><\/div><\/div><div><div><span>};<\/span><\/div><\/div><div><div>\n<\/div><\/div><div><div><span>type<\/span><span> <\/span><span>WorkflowStepContext<\/span><span> <\/span><span>=<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>step<\/span><span>:<\/span><span><span> <\/span><span>{<\/span><\/span><\/div><\/div><div><div><span><span>    <\/span><\/span><span>name<\/span><span>:<\/span><span> <\/span><span>string<\/span><span>;<\/span><\/div><\/div><div><div><span><span>    <\/span><\/span><span>count<\/span><span>:<\/span><span> <\/span><span>number<\/span><span>;<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>};<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>attempt<\/span><span>:<\/span><span> <\/span><span>number<\/span><span>;<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>config<\/span><span>:<\/span><span> <\/span><span>ResolvedStepConfig<\/span><span>;<\/span><\/div><\/div><div><div><span>};<\/span><\/div><\/div><\/code><\/pre>\n<div>\n<div><\/div>\n<\/div>\n<div><\/div>\n<\/figure>\n<\/div>\n<h4>ReadableStream support in <code>step.do()<\/code><\/h4>\n<p>Steps can now return a <code>ReadableStream<\/code> directly. Although non-stream step outputs are <a href=\"https:\/\/developers.cloudflare.com\/workflows\/reference\/limits\/\">limited to 1 MiB<\/a>, streamed outputs support much larger payloads.<\/p>\n<div>\n<figure>\n<pre data-language=\"ts\"><code class=\"language-ts\"><div><div><span>const<\/span><span> <\/span><span>largePayload<\/span><span> <\/span><span>=<\/span><span> <\/span><span>await<\/span><span> <\/span><span>step<\/span><span>.<\/span><span>do<\/span><span>(<\/span><span>\"fetch-large-file\"<\/span><span>,<\/span><span> <\/span><span>async<\/span><span> <\/span><span>()<\/span><span> <\/span><span>=&gt;<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>const<\/span><span> <\/span><span>object<\/span><span> <\/span><span>=<\/span><span> <\/span><span>await<\/span><span> <\/span><span>env<\/span><span>.<\/span><span>MY_BUCKET<\/span><span>.<\/span><span>get<\/span><span>(<\/span><span>\"large-file.bin\"<\/span><span>)<\/span><span>;<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>return<\/span><span> <\/span><span>object<\/span><span>.<\/span><span>body<\/span><span>;<\/span><\/div><\/div><div><div><span>}<\/span><span>)<\/span><span>;<\/span><\/div><\/div><\/code><\/pre>\n<div>\n<div><\/div>\n<\/div>\n<\/figure>\n<\/div>\n<p>Note that streamed outputs are still considered part of the Workflow instance storage limit.<\/p>","protected":false},"excerpt":{"rendered":"<p>Workflows now provides additional context inside step.do() callbacks and supports returning ReadableStream to handle larger step outputs. Step context properties The step.do() callback receives a context object with new properties alongside attempt: step.name \u2014 The name passed to step.do() step.count \u2014 How many times a step with that name has been invoked in this instance [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-391","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts\/391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts\/391\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/media?parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/categories?post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/tags?post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}