# JavaScript retry libraries

JavaScript retry libraries run a failed operation again after a delay until it succeeds or reaches an attempt limit. Each delay usually grows exponentially, with random jitter that keeps many clients from retrying at the same moment. These libraries let apps and AI agents recover from network errors, rate limits, and brief outages in the APIs they call.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [retry](#retry) | 618.4M | 1.3K | Jun 2021 | MIT |
| [@humanwhocodes/retry](#humanwhocodes-retry) | 607.8M | Not on GitHub | May 2025 | Apache-2.0 |
| [Async](#async) | 559.9M | Not on GitHub | Aug 2024 | MIT |
| [es-toolkit](#es-toolkit) | 320.3M | Not on GitHub | Nov 2026 | MIT |
| [p-retry](#p-retry) | 276.5M | 1.0K | Nov 2026 | MIT |
| [exponential-backoff](#exponential-backoff) | 218.7M | Not on GitHub | Oct 2025 | Apache-2.0 |
| [async-retry](#async-retry) | 190.2M | 1.9K | Aug 2021 | MIT |
| [promise-retry](#promise-retry) | 136.7M | Not on GitHub | Jun 2020 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[retry](#retry) has the most monthly downloads in this comparison, at 603.0M.

## Capabilities

| Library | Native AbortSignal | Configurable jitter | Shared retry queue |
| --- | --- | --- | --- |
| [retry](#retry) | No | Yes | No |
| [@humanwhocodes/retry](#humanwhocodes-retry) | Yes | No | Yes |
| [Async](#async) | No | No | No |
| [es-toolkit](#es-toolkit) | Yes | No | No |
| [p-retry](#p-retry) | Yes | Yes | No |
| [exponential-backoff](#exponential-backoff) | No | Yes | No |
| [async-retry](#async-retry) | No | Yes | No |
| [promise-retry](#promise-retry) | No | Yes | No |

## Libraries

### retry

[GitHub](https://github.com/tim-kos/node-retry) · [npm](https://www.npmjs.com/package/retry) · [Docs](https://api.github.com/repos/tim-kos/node-retry/readme)

Provides callback-oriented retry operations with configurable backoff and explicit attempt control.

- Downloads / mo: 618.4M
- Stars: 1.3K
- Last release: 0.13.1
- License: MIT
- Capabilities: [From the retry docs](https://api.github.com/repos/tim-kos/node-retry/readme)

**Strengths**

- **Exposes explicit attempt control.** Use attempt, retry, and stop to control callback operations.
- **Supports custom delay schedules.** Pass an array of timeouts when exponential backoff does not fit.

**Watch out for**

- **Callbacks must request another attempt.** Call operation.retry(error) to schedule the next attempt.
- **Reports the most frequent error.** mainError selects the most frequent message rather than the last failure.

```sh
npm install retry@0.13.1
```

**IndigoUnited/node-promise-retry** (319 stars)

[IndigoUnited/node-promise-retry](https://github.com/IndigoUnited/node-promise-retry) 

```javascript
function promiseRetry(fn, options) {
    var temp;
    var operation;

    if (typeof fn === 'object' && typeof options === 'function') {
        // Swap options and fn when using alternate signature (options, fn)
        temp = options;
        options = fn;
        fn = temp;
    }

    operation = retry.operation(options);

    return new Promise(function (resolve, reject) {
        operation.attempt(function (number) {
            Promise.resolve()
            .then(function () {
                return fn(function (err) {
                    if (isRetryError(err)) {
                        err = err.retried;
                    }

                    throw errcode(new Error('Retrying'), 'EPROMISERETRY', { retried: err });
                }, number);
            })
            .then(resolve, function (err) {
                if (isRetryError(err)) {
                    err = err.retried;

                    if (operation.retry(err || new Error())) {
                        return;
                    }
                }

                reject(err);
            });
        });
    });
}

```

[index.js](https://github.com/IndigoUnited/node-promise-retry/blob/7fb08491112cffe5a0dd11805eff20ca6b6133ac/index.js#L12-L50) · [More projects using retry →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20using%20retry%20for%20conditional%20async%20retries%2C%20backoff%2C%20bailout%2C%20callbacks%20and%20HTTP%20interceptor%20configuration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import retry from 'retry';

const operation = retry.operation({ retries: 2 });
operation.attempt(attempt => {
  const error = attempt < 2 ? new Error('Not ready') : null;
  if (operation.retry(error)) return;
  console.log(error ?? 'ready');
});

```

From [README.md](https://api.github.com/repos/tim-kos/node-retry/readme)

### @humanwhocodes/retry

[GitHub](https://github.com/humanwhocodes/retry) · [npm](https://www.npmjs.com/package/@humanwhocodes/retry) · [Docs](https://api.github.com/repos/humanwhocodes/retry/readme)

Retries selected failures through a shared Retrier queue.

- Downloads / mo: 607.8M
- Last release: 0.4.3
- License: Apache-2.0
- Capabilities: [From the @humanwhocodes/retry docs](https://api.github.com/repos/humanwhocodes/retry/readme)

```sh
npm install @humanwhocodes/retry@0.4.3
```

**humanwhocodes/humanfs** (557 stars)

[humanwhocodes/humanfs](https://github.com/humanwhocodes/humanfs) 

```javascript
async write(filePath, contents) {
	const value = Buffer.from(contents);

	return this.#retrier
		.retry(() => this.#fsp.writeFile(filePath, value))
		.catch(error => {
			// the directory may not exist, so create it
			if (error.code === "ENOENT") {
				const dirPath = path.dirname(
					filePath instanceof URL
						? fileURLToPath(filePath)
						: filePath,
				);

				return this.#fsp
					.mkdir(dirPath, { recursive: true })
					.then(() => this.#fsp.writeFile(filePath, value));
			}

			throw error;
		});
}

```

[packages/node/src/node-hfs.js](https://github.com/humanwhocodes/humanfs/blob/c985e4aebfd23d02c0eb289578eea613118ccc14/packages/node/src/node-hfs.js#L138-L159) · [More projects using @humanwhocodes/retry →](https://dashboard.exa.ai/playground/search?q=%40humanwhocodes/retry%20GitHub%20projects)

**Quickstart**

```javascript
import { Retrier } from '@humanwhocodes/retry';

const retrier = new Retrier(error => error.code === 'EMFILE');
const value = await retrier.retry(async () => 'ready');

```

From [README.md](https://api.github.com/repos/humanwhocodes/retry/readme)

### Async

[GitHub](https://github.com/caolan/async) · [npm](https://www.npmjs.com/package/async) · [Docs](https://api.github.com/repos/caolan/async/readme)

Provides a control-flow toolkit with a built-in retry function.

- Downloads / mo: 559.9M
- Last release: 3.2.6
- License: MIT
- Capabilities: [From the Async docs](https://api.github.com/repos/caolan/async/readme)

```sh
npm install async@3.2.6
```

**mallocator/Elasticsearch-Exporter** (593 stars)

[mallocator/Elasticsearch-Exporter](https://github.com/mallocator/Elasticsearch-Exporter) 

```javascript
(results, callback) => {
    async.retry(exports.env.options.errors.retry, callback => {
        log.debug('Fetching source statistics before starting run');
        let source = drivers.get(exports.env.options.drivers.source).driver;
        source.getSourceStats(exports.env, (err, sourceStats) => {
            exports.env.statistics.source = util._extend(exports.env.statistics.source, sourceStats);
            callback(err);
        });
    }, callback);
}

```

[exporter.js](https://github.com/mallocator/Elasticsearch-Exporter/blob/b6052179cdf7be53739a7b58e876b1003a457f6b/exporter.js#L186-L195) · [More projects using Async →](https://dashboard.exa.ai/playground/search?q=async%20GitHub%20projects)

**Quickstart**

```javascript
import async from 'async';

const value = await async.retry({ times: 3 }, async () => 'ready');

```

From [README.md](https://api.github.com/repos/caolan/async/readme)

### es-toolkit

[GitHub](https://github.com/toss/es-toolkit) · [npm](https://www.npmjs.com/package/es-toolkit) · [Docs](https://api.github.com/repos/toss/es-toolkit/readme)

Provides a utility toolkit with a built-in promise retry function.

- Downloads / mo: 320.3M
- Last release: 1.53.2
- License: MIT
- Capabilities: [From the es-toolkit docs](https://api.github.com/repos/toss/es-toolkit/readme)

```sh
npm install es-toolkit@1.53.2
```

**nonbili/NouTube** (1.5K stars)

[nonbili/NouTube](https://github.com/nonbili/NouTube) 

```javascript
export async function playDefaultAudio() {
  await retry(
    () => {
      if (!player) {
        throw 'player not ready'
      }
      return player
    },
    { retries: 30, delay: 100 },
  )
  player?.playVideo()
  const audioTracks: any[] = await retry(
    () => {
      const tracks = player?.getAvailableAudioTracks?.() || []
      if (!tracks.length) {
        throw 'tracks not ready'
      }
      return tracks
    },
    { retries: 30, delay: 100 },
  )
  let options = ''
  let selected
  let i = 0
  for (const track of audioTracks) {
    for (let v of Object.values(track)) {
      const value = v as any
      if (value && typeof value == 'object' && 'isDefault' in value && value.name) {
        if (originalLabels.some((x) => value.name.includes(x))) {
          selected = i.toString()
          player?.setAudioTrack?.(track)
        }
        options += `<option value="${i}">${value.name}</option>`
      }
    }
    i++
  }

  let container = document.querySelector('div#_nou_audio_picker')
  if (!container) {
    container = document.createElement('div')
    container.id = '_nou_audio_picker'
    document.body.append(container)
  }
  container.innerHTML = nouPolicy.createHTML(/* HTML */ `
    <select>
      ${options}
    </select>
  `)
  const select = container.querySelector('select')
  if (select) {
    if (selected) {
      select.value = selected
    }
    select.onchange = (e) => {
      const i = (e.target as HTMLSelectElement).value
      if (i != null) {
        player?.setAudioTrack?.(audioTracks[+i])
      }
    }
  }
}

```

[content/player.ts](https://github.com/nonbili/NouTube/blob/b89f59eed7ceb651295ccc39f469a056acd5541a/content/player.ts#L490-L551) · [More projects using es-toolkit →](https://dashboard.exa.ai/playground/search?q=es-toolkit%20GitHub%20projects)

**Quickstart**

```javascript
import { retry } from 'es-toolkit';

const value = await retry(async () => 'ready', { retries: 2 });

```

From [README.md](https://api.github.com/repos/toss/es-toolkit/readme)

### p-retry

[GitHub](https://github.com/sindresorhus/p-retry) · [npm](https://www.npmjs.com/package/p-retry) · [Docs](https://api.github.com/repos/sindresorhus/p-retry/readme)

Retries promise-returning operations with backoff, retry budgets, and cancellation signals.

- Downloads / mo: 276.5M
- Stars: 1.0K
- Last release: 9.0.0
- License: MIT
- Capabilities: [From the p-retry docs](https://api.github.com/repos/sindresorhus/p-retry/readme)

**Strengths**

- **Separates failures from retry budgets.** Use shouldConsumeRetry when selected failures should preserve the retry budget.
- **Accepts cancellation signals.** Pass an AbortSignal to stop retrying.

**Watch out for**

- **Cancellation leaves running attempts active.** Pass the signal into the operation to cancel its underlying work.
- **Time limits allow running overruns.** Attempts and callbacks can finish after maxRetryTime.

```sh
npm install p-retry@9.0.0
```

**slackapi/node-slack-sdk** (3.4K stars)

[slackapi/node-slack-sdk](https://github.com/slackapi/node-slack-sdk) 

```javascript
public async send(message: string | IncomingWebhookSendArguments): Promise<IncomingWebhookResult> {
  let payload: IncomingWebhookSendArguments = { ...this.defaults };

  if (typeof message === 'string') {
    payload.text = message;
  } else {
    payload = Object.assign(payload, message);
  }

  // Remove transport options so they don't leak into payloads
  const { fetch: _fetch, timeout: _timeout, retryConfig: _retryConfig, ...messagePayload } = payload;

  return pRetry(async () => {
    const signal = this.timeout > 0 ? AbortSignal.timeout(this.timeout) : undefined;

    try {
      const response = await this.fetchFn(this.url, {
        method: 'POST',
        headers: {
          ...this.headers,
          'Content-Type': 'application/json',
        },
        body: JSON.stringify(messagePayload),
        redirect: 'error',
        signal,
      });

      if (!response.ok) {
        const body = await response.text();
        const httpError = new IncomingWebhookHTTPError(response.status, response.statusText, body);
        // Only server errors (5xx) are transient; client errors (4xx), including rate limits (429), fail immediately.
        throw response.status >= 500 ? httpError : new AbortError(httpError);
      }

      return await this.buildResult(response);
    } catch (error) {
      // Non-retryable signals (AbortError) and already-wrapped errors pass through untouched.
      if (error instanceof AbortError || error instanceof SlackWebhookError) {
        throw error;
      }
      // No response received (network/timeout): retryable.
      throw new IncomingWebhookRequestError(error instanceof Error ? error : new Error(String(error)));
    }
  }, this.retryConfig);
}

```

[packages/webhook/src/IncomingWebhook.ts](https://github.com/slackapi/node-slack-sdk/blob/6fc548b75e8bef578008d2dd2787805d616833e8/packages/webhook/src/IncomingWebhook.ts#L93-L137) · [More projects using p-retry →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20using%20p-retry%20for%20conditional%20async%20retries%2C%20backoff%2C%20bailout%2C%20callbacks%20and%20HTTP%20interceptor%20configuration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import pRetry, {AbortError} from 'p-retry';

const run = async () => {
	const response = await fetch('https://sindresorhus.com/unicorn');

	// Abort retrying if the resource doesn't exist
	if (response.status === 404) {
		throw new AbortError(response.statusText);
	}

	return response.blob();
};

console.log(await pRetry(run, {retries: 5}));

```

From [readme.md](https://api.github.com/repos/sindresorhus/p-retry/readme)

### exponential-backoff

[GitHub](https://github.com/coveooss/exponential-backoff) · [npm](https://www.npmjs.com/package/exponential-backoff) · [Docs](https://api.github.com/repos/coveooss/exponential-backoff/readme)

Retries promises with an explicit attempt count, exponential delay bounds, and jitter.

- Downloads / mo: 218.7M
- Last release: 3.1.3
- License: Apache-2.0
- Capabilities: [From the exponential-backoff docs](https://api.github.com/repos/coveooss/exponential-backoff/readme)

```sh
npm install exponential-backoff@3.1.3
```

**Quickstart**

```javascript
import { backOff } from 'exponential-backoff';

const value = await backOff(async () => 'ready', { numOfAttempts: 3 });

```

From [README.md](https://api.github.com/repos/coveooss/exponential-backoff/readme) · [Find projects using exponential-backoff →](https://dashboard.exa.ai/playground/search?q=exponential-backoff%20GitHub%20projects)

### async-retry

[GitHub](https://github.com/vercel/async-retry) · [npm](https://www.npmjs.com/package/async-retry) · [Docs](https://api.github.com/repos/vercel/async-retry/readme)

Retries async callbacks with a bail function and node-retry timing options.

- Downloads / mo: 190.2M
- Stars: 1.9K
- Last release: 1.3.3
- License: MIT
- Capabilities: [From the async-retry docs](https://api.github.com/repos/vercel/async-retry/readme)

**Strengths**

- **Provides an explicit bailout callback.** Call bail for failures that should stop retrying.
- **Supports randomized backoff.** Configure exponential delays and randomized timeouts through the retry options.

**Watch out for**

- **Bail leaves callback execution active.** Return after bail to prevent the callback from continuing.

```sh
npm install async-retry@1.3.3
```

**vercel/next.js** (143.7K stars)

[vercel/next.js](https://github.com/vercel/next.js) 

```javascript
export async function retry<T>(
  fn: asyncRetry.RetryFunction<T>,
  retries: number
) {
  return await asyncRetry(fn, {
    retries,
    onRetry(e: unknown, attempt: unknown) {
      console.error(
        (e as Error).message + `\n\nRetrying ${attempt}/${retries}...`
      )
    },
    minTimeout: 100,
  })
}

```

[packages/font/src/google/retry.ts](https://github.com/vercel/next.js/blob/ad4859b599128915430ab68bcf344bddf81c0177/packages/font/src/google/retry.ts#L4-L17) · [More projects using async-retry →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20using%20async-retry%20for%20conditional%20async%20retries%2C%20backoff%2C%20bailout%2C%20callbacks%20and%20HTTP%20interceptor%20configuration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import retry from 'async-retry';

const value = await retry(async () => 'ready', { retries: 2 });

```

From [README.md](https://api.github.com/repos/vercel/async-retry/readme)

### promise-retry

[GitHub](https://github.com/IndigoUnited/node-promise-retry) · [npm](https://www.npmjs.com/package/promise-retry) · [Docs](https://api.github.com/repos/IndigoUnited/node-promise-retry/readme)

Retries promises through an explicit retry callback with the attempt number.

- Downloads / mo: 136.7M
- Last release: 2.0.1
- License: MIT
- Capabilities: [From the promise-retry docs](https://api.github.com/repos/IndigoUnited/node-promise-retry/readme)

```sh
npm install promise-retry@2.0.1
```

**prymitive/karma** (2.7K stars)

[prymitive/karma](https://github.com/prymitive/karma) 

```javascript
const FetchGet = async (
  uri: string,
  options: RequestInit,
  beforeRetry: PreRetryCallback,
): Promise<Response> =>
  await promiseRetry(
    (retry, number) =>
      fetch(uri, {
        ...{ method: "GET" },
        ...CommonOptions,
        mode: number <= FetchRetryConfig.retries ? "cors" : "no-cors",
        ...options,
      }).catch((err) => {
        beforeRetry && beforeRetry(number);
        return retry(err);
      }),
    FetchRetryConfig,
  );

```

[ui/src/Common/Fetch.ts](https://github.com/prymitive/karma/blob/0fd7f17ab01d76d6c8c0a316d1a2c5a17c2d78c7/ui/src/Common/Fetch.ts#L17-L34) · [More projects using promise-retry →](https://dashboard.exa.ai/playground/search?q=promise-retry%20GitHub%20projects)

**Quickstart**

```javascript
import promiseRetry from 'promise-retry';

const value = await promiseRetry(async () => 'ready', { retries: 2 });

```

From [README.md](https://api.github.com/repos/IndigoUnited/node-promise-retry/readme)

## FAQ

### Which JavaScript retry library should I use?

[p-retry](#p-retry) suits promise-returning functions that need backoff, jitter, and AbortSignal cancellation. [exponential-backoff](#exponential-backoff) suits code that wants explicit delay bounds and jitter settings. Projects that already use [es-toolkit](#es-toolkit) or [Async](#async) can use their built-in retry functions.

### What is exponential backoff?

Exponential backoff multiplies the wait before each retry by a constant factor. A maximum delay caps the growth, and jitter randomizes each wait.

### What is p-retry?

[p-retry](#p-retry) retries a promise-returning function with configurable randomized backoff. An AbortError or AbortSignal stops the retries early.

### p-retry vs async-retry: which should I use?

[p-retry](#p-retry) supports AbortSignal and error-aware hooks. [async-retry](#async-retry) passes a bail function to the task and uses the timing options of the retry package.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript retry libraries p-retry async-retry retry axios-retry code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
