• Version 1.4.8
  • Published
  • 5.91 kB
  • 1 dependency
  • MIT license


npm i @types/async-retry
yarn add @types/async-retry
pnpm add @types/async-retry


TypeScript definitions for async-retry




Type Aliases


function AsyncRetry

AsyncRetry: <TRet>(
fn: AsyncRetry.RetryFunction<TRet>,
opts?: AsyncRetry.Options
) => Promise<TRet>;
  • Retrying made simple, easy, and async.

    Example 1

    import retry = require('async-retry'); import fetch from 'node-fetch';

    await retry( async (bail) => { // if anything throws, we retry const res = await fetch('https://google.com');

    if (403 === res.status) { // don't retry upon 403 bail(new Error('Unauthorized')); return; }

    const data = await res.text(); return data.substr(0, 500); }, { retries: 5, } );


interface Options

interface Options extends WrapOptions {}

    property onRetry

    onRetry?: ((e: Error, attempt: number) => any) | undefined;
    • An optional function that is invoked after a new retry is performed. It's passed the Error that triggered it as a parameter.

    Type Aliases

    type RetryFunction

    type RetryFunction<TRet> = (
    bail: (e: Error) => void,
    attempt: number
    ) => TRet | Promise<TRet>;
    • Parameter bail

      A function you can invoke to abort the retrying (bail).

      Parameter attempt

      The attempt number. The absolute first attempt (before any retries) is 1.

    Package Files (1)

    Dependencies (1)

    Dev Dependencies (0)

    No dev dependencies.

    Peer Dependencies (0)

    No peer dependencies.


    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/async-retry.

    • Markdown
    • HTML
      <a href="https://www.jsdocs.io/package/@types/async-retry"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>