Skip to content

Type Alias: RetryOptions<T> ​

RetryOptions<T> = object

Defined in: packages/promise/dist/index.d.ts:163

Options for automatic retry mechanism

Type Parameters ​

T ​

T = unknown

Properties ​

retry? ​

optional retry?: number

Defined in: packages/promise/dist/index.d.ts:171

Maximum number of retries.

The total number of attempts will be retry + 1.

Default: 1


retryBackOff? ​

optional retryBackOff?: "exponential" | "linear"

Defined in: packages/promise/dist/index.d.ts:178

Accepted values:

  • exponential: each subsequent retry delay will be doubled from the last
  • linear: fixed delay between retries Default: 'exponential'

retryDelay? ​

optional retryDelay?: number

Defined in: packages/promise/dist/index.d.ts:185

The base delay in milliseconds between retries. Default: 300

Setting this to 0 disables the delay mechanism entirely, including jitter.


retryDelayJitter? ​

optional retryDelayJitter?: boolean

Defined in: packages/promise/dist/index.d.ts:193

Whether to add a random delay between 0ms and retryDelayJitterMax to the retryDelay.

This helps to avoid "thundering herd" problem when multiple retries are attempted simultaneously.

Default: true


retryDelayJitterMax? ​

optional retryDelayJitterMax?: number

Defined in: packages/promise/dist/index.d.ts:201

Maximum jitter delay (in milliseconds) to be added to the retryDelay when retryDelayJitter is true.

A random value between 0 and retryDelayJitterMax will be added to the base retryDelay.

Default: 100


retryIf? ​

optional retryIf?: RetryIfFunc<T>

Defined in: packages/promise/dist/index.d.ts:217

Additional condition to be used to determine whether function should be retried.

If retryIf not provided, execution will be retried on any error until the retry limit is reached or a result is received without an exception.

Param ​

prevResult

The result from the previous attempt, if any.

Param ​

retryCount

The number of retries that have been attempted so far.

Param ​

error

The error from the previous attempt, if any.

Expected return values:

  • true: retry will be attempted regardless of error.
  • false: no further retry will be attempted and the last error/result will be returned.
  • void | undefined: retry will be attempted only if there was an error.