Workflows - Workflows now supports delay functions when retrying
7h ago
From the article
With Workflows , you can configure built-in retry behavior for each step. Previously, you could configure step retries with fixed delay durations, such as seconds, minutes, or hours, and backoff strategies such as constant , linear , or exponential . Step retries now support dynamic delay functions. Instead of choosing only a base delay and backoff strategy, pass a function to retries.delay and calculate the next delay from the failed attempt and thrown error. This is useful when retries should depend on the failure. Your Workflow may need to wait longer after a rate-limit error, but retry sooner after a short network failure. The delay function can also accommodate provider guidance if, for example, a downstream API returns a Retry-After value in its error messaging. JavaScript await step . do ( "sync customer" , { retries : { limit : 5 , delay : ({ ctx , error }) => { if ( error . message . includes ( "rate limit" )) { return ` ${ ctx . attempt * 30 } seconds` ; } return "10 seconds" ; }, }, }, async () => { await syncCustomer () ; }, ) ; TypeScript await step . do ( "sync customer" , { retries : { limit : 5 , delay : ({ ctx , error }) => { if ( error . message . includes ( "rate limit" )) { return ` ${ ctx . attempt * 30 } seconds` ; } return "10 seconds" ; }, }, }, async () => { await syncCustomer () ; }, ) ; Dynamic delay functions can return a duration string, a number, or a promise that resolves to a duration. Use them to add adaptive retry behavior without writing separate queue or scheduling logic. For more information, refer to Sleeping and retrying .
Continue reading on CloudflareYou might also wanna read
Workflow SDK: Adding Durability and Reliability to TypeScript Functions
The article introduces Workflow SDK, a tool that adds durability, reliability, and observability to asynchronous JavaScript/TypeScript funct
AWS Step Functions with Lambda for .NET Workflows
codewithmukesh.com·1y ago
Technical Comparison: n8n vs Windmill vs Temporal for Self-Hosted Workflow Automation
This technical analysis compares three workflow automation platforms - n8n, Windmill, and Temporal - specifically for self-hosted deployment
Understanding JavaScript Promise Cancellation: Why It Doesn't Exist and Workaround Alternatives
This article explores the technical challenge of canceling JavaScript promises, explaining why there's no built-in cancellation mechanism de
A Practical Guide to Swift Concurrency: Understanding Async/Await, Actors, and MainActor
This article provides a straightforward, jargon-free guide to Swift's concurrency system, focusing on making complex concepts approachable.
Optimizing Async Loops in JavaScript: Avoiding Common Performance Pitfalls
This article explores common pitfalls with using 'await' in JavaScript loops and provides solutions for optimizing asynchronous code perform

Comments
Sign in to join the conversation.
No comments yet. Be the first.