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

PropertyTypeDescriptionDefined in
factor?numberMultiplier 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?numberInitial 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?numberRandom 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?numberMaximum 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?numberMaximum 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) => voidOptional 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?AbortSignalOptional AbortSignal to cancel retries. If the signal is aborted, the retry operation stops and returns a RetryAbortError.packages/common/src/Promise.ts:61

Was this page helpful?