RetryConfig
Pass aretry object to Workflow.step():
Number of retry attempts, not counting the initial execution.
maxAttempts: 3 means up to 4 total executions.Delay between retry attempts. Accepts a human-readable string, milliseconds, a
Backoff strategy, or a custom function. When omitted, defaults to exponential backoff starting at 1 second (capped at 60 seconds).Add random variance to delays to avoid synchronized retries across many clients (the “thundering herd” problem). Defaults to
true.Total time budget across all attempts. If elapsed time exceeds this value, the step fails with
RetryExhaustedError even if maxAttempts has not been reached.Predicate called on each failure. Return
false to stop retrying for specific error types. All errors are retryable by default.Backoff strategies
Import theBackoff namespace for built-in strategies:
Exponential
Delay grows asbase × factor^attempt. This is the most common strategy for external APIs.
Linear
Delay grows asinitial + (attempt × increment).
Constant
Fixed delay between every retry.Custom function
For fully custom delay logic, pass a function that receives the current attempt number (1-indexed) and returns milliseconds:Presets
Use built-in presets for common scenarios:| Preset | Behavior | Use case |
|---|---|---|
Backoff.presets.standard() | 1s → 2s → 4s → 8s → 16s (max 30s) | General external APIs |
Backoff.presets.aggressive() | 100ms → 200ms → 400ms → 800ms (max 5s) | Internal services, low latency |
Backoff.presets.patient() | 5s → 10s → 20s → 40s (max 2min) | Rate-limited APIs |
Backoff.presets.simple() | 1s constant | Polling |
Jitter
Jitter adds a random offset to each computed delay. When many workflow instances fail at the same time and all retry with identical delays, they can overwhelm a downstream service simultaneously. Jitter staggers the retries. To disable jitter when precise timing matters:Max duration
maxDuration sets a wall-clock budget for the entire retry sequence. Combine it with a high maxAttempts when you want best-effort retries within a fixed window:
Selective retry with isRetryable
Use isRetryable to retry only specific error types. This is useful when some failures are permanent (validation errors, not-found errors) and others are transient (network errors, rate limits).
ValidationError will fail the step immediately. NetworkError will trigger up to 5 retries.
Timeouts
Set a per-attempt deadline withtimeout:
Timeout with retry
When bothtimeout and retry are configured, the timeout applies to each attempt individually — not to the total time:
isRetryable returns true for WorkflowTimeoutError.
Duration format
Bothtimeout and delay accept the same formats:
