{"id":276,"date":"2026-03-06T12:00:00","date_gmt":"2026-03-06T12:00:00","guid":{"rendered":"https:\/\/wordpress.securinsight.ca\/index.php\/2026\/03\/06\/workflows-workers-workflow-steps-now-expose-retry-attempt-number-via-step-context\/"},"modified":"2026-03-06T12:00:00","modified_gmt":"2026-03-06T12:00:00","slug":"workflows-workers-workflow-steps-now-expose-retry-attempt-number-via-step-context","status":"publish","type":"post","link":"https:\/\/wordpress.securinsight.ca\/index.php\/2026\/03\/06\/workflows-workers-workflow-steps-now-expose-retry-attempt-number-via-step-context\/","title":{"rendered":"Workflows, Workers &#8211; Workflow steps now expose retry attempt number via step context"},"content":{"rendered":"<p>Cloudflare Workflows allows you to configure specific retry logic for each step in your workflow execution. Now, you can access <strong>which<\/strong> retry attempt is currently executing for calls to <code>step.do()<\/code>:<\/p>\n<div>\n<figure>\n<pre data-language=\"ts\"><code class=\"language-ts\"><div><div><span>await<\/span><span> <\/span><span>step<\/span><span>.<\/span><span>do<\/span><span>(<\/span><span>\"my-step\"<\/span><span>,<\/span><span> <\/span><span>async<\/span><span> <\/span><span>(<\/span><span>ctx<\/span><span>)<\/span><span> <\/span><span>=&gt;<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span>  <\/span><span>\/\/ ctx.attempt is 1 on first try, 2 on first retry, etc.<\/span><\/div><\/div><div><div><span><span>  <\/span><\/span><span>console<\/span><span>.<\/span><span>log<\/span><span>(<\/span><span>`Attempt <\/span><span>${<\/span><span>ctx<\/span><span>.<\/span><span>attempt<\/span><span>}<\/span><span>`<\/span><span>)<\/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>You can use the step context for improved logging &amp; observability, progressive backoff, or conditional logic in your workflow definition.<\/p>\n<p>Note that the current attempt number is 1-indexed. For more information on retry behavior, refer to <a href=\"https:\/\/developers.cloudflare.com\/workflows\/build\/sleeping-and-retrying\/\">Sleeping and Retrying<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Cloudflare Workflows allows you to configure specific retry logic for each step in your workflow execution. Now, you can access which retry attempt is currently executing for calls to step.do(): await step.do(&#8220;my-step&#8221;, async (ctx) =&gt; { \/\/ ctx.attempt is 1 on first try, 2 on first retry, etc. console.log(`Attempt ${ctx.attempt}`);}); You can use the step [&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-276","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts\/276","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=276"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts\/276\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/media?parent=276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/categories?post=276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/tags?post=276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}