Skip to content

Type Alias: RetryOptions<T>

RetryOptions<T> = object

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

Options for automatic retry mechanism

Type Parameters

T

T = unknown

Properties

retry?

optional retry: number

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

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:169

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:174

Minimum delay in milliseconds between retries. Default: 300


retryDelayJitter?

optional retryDelayJitter: boolean

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

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:190

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:206

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

The result from the previous attempt, if any.

Param

The number of retries that have been attempted so far.

Param

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.