Interface AsyncRetryArgs<T>

Args object for asyncRetry

interface AsyncRetryArgs<T> {
    asyncFn: (() => Promise<T>);
    maxRetrials?: number;
    onFailureAsync: ((e: Error, retryCount: number) => Promise<boolean>);
    retryCount?: number;
}

Type Parameters

  • T

Properties

asyncFn: (() => Promise<T>)

The promise to be executed. It needs to throw an error in case of failure

maxRetrials?: number

The absolute maximum number of retrials. Default: 20

onFailureAsync: ((e: Error, retryCount: number) => Promise<boolean>)

The callback in case of a failure of asyncFn. Can be used to prepare something before as asyncFn is being called next

Type declaration

    • (e, retryCount): Promise<boolean>
    • Parameters

      • e: Error

        The error thrown by asyncFn

      • retryCount: number

        The number of retrials (incremented automatically) so far

      Returns Promise<boolean>

      true if asyncFn should be called again, or false

retryCount?: number

The counter of retrials. It is managed automatically, so you do not need to set this