API Reference / @evolu/common / Promise / RetryOptions
Interface: RetryOptions<E>
Defined in: packages/common/src/Promise.ts:22
Options for configuring retry behavior.
Type Parameters
Type Parameter |
---|
E |
Properties
Property | Type | Description | Defined in |
---|---|---|---|
factor? | number | Multiplier that determines how quickly the delay increases (default: 2). With the default value, each successive delay is twice as long as the previous one (e.g., 100ms, 200ms, 400ms, 800ms, etc). | packages/common/src/Promise.ts:49 |
initialDelay? | number | Initial delay between retry attempts in milliseconds (default: 100). This is the delay after the first failed attempt. Subsequent delays increase exponentially according to the factor option. | packages/common/src/Promise.ts:35 |
jitter? | number | Random jitter factor between 0 and 1 (default: 0.1). Adds randomness to delay times to prevent retry storms in distributed systems. | packages/common/src/Promise.ts:55 |
maxDelay? | number | Maximum delay between retry attempts in milliseconds (default: 10000). This caps the exponential backoff to prevent extremely long delays after many retries. | packages/common/src/Promise.ts:42 |
maxRetries? | number | Maximum number of retry attempts after the initial attempt (default: 3). For example, with maxRetries = 3, the function will be called up to 4 times (1 initial attempt + 3 retries). | packages/common/src/Promise.ts:28 |
onRetry? | (error , attempt , delay ) => void | Optional callback called before each retry attempt. Receives the error that caused the retry, the current attempt number (starting at 1), and the delay in milliseconds before the next attempt. | packages/common/src/Promise.ts:76 |
retryable? | Predicate <E > | Optional predicate to determine if an error should be retried. Returns true if the error is retryable, false otherwise. This allows selectively retrying only certain types of errors. By default, all errors are considered retryable. | packages/common/src/Promise.ts:69 |
signal? | AbortSignal | Optional AbortSignal to cancel retries. If the signal is aborted, the retry operation stops and returns a RetryAbortError. | packages/common/src/Promise.ts:61 |