interface RetryOnConflictParams<T> {
    delayMs?: number;
    executeFn: ((attemptNo) => Promise<T>);
    jitter?: boolean;
    maxRetries?: number;
}

Type Parameters

  • T = any

Properties

delayMs?: number

The number of milliseconds to wait before retrying a failed request. This will be increased exponentially CommercetoolsApi.calculateDelay. Defaults to 100.

executeFn: ((attemptNo) => Promise<T>)

Any function that returns a promise

This function is expected to be able to throw a CommercetoolsError with a status code of 409. These errors should not be swallowed by the code in this function.

Type declaration

    • (attemptNo): Promise<T>
    • Parameters

      • attemptNo: number

      Returns Promise<T>

jitter?: boolean

If enabled, adds a random element to the exponential increase in retry time. See the following url for more details: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ We utilise the 'full' jitter + plus an additional decaying variance.

maxRetries?: number

The maximum number of times that we'll call the executeFn function before returning the error caught from the last failure. Defaults to 3.