Signature
tsSignature
export function retry<I, O, E, C extends object>( source: Behavior<I, O, E, C>, options: RetryOptions<E>,): Behavior<I, O, E, C>;Imports
tsImport
import { retry } from "@/lib/flow/retry";import { retry } from "@/lib/flow";Type Parameters
Parameters
optionsRetryOptions<E>
Retry attempts, optional delay, and optional predicate.
Returns
A behavior with the same success and domain error types as the source.
Return type
Behavior<I, O, E, C>Details
The source is run at most `options.attempts` times. Runtime errors and cancellation return
immediately. Cancellation during a retry delay returns `Cancelled`.
Examples
tsExample
const resilientLoad = retry(loadUser, { attempts: 3, delay: (attempt) => attempt * 100, when: (error) => error.kind === "rate-limited",});Related Symbols
Behavior
Executable Flow workflow unit.
type
delay
Waits before running a source behavior.
function
RetryOptions
Configuration for retrying expected domain failures.
type
run
Runs a behavior with an optional application context.
function
Source
tsflow/retry.ts:61-66
export function retry<I, O, E, C extends object>( source: Behavior<I, O, E, C>, options: RetryOptions<E>,): Behavior<I, O, E, C> { return retryBehavior(source, retryPolicy(options));}