npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bybrave/async-retry2

v2.0.2

Published

Maintained async-retry fork: zero runtime dependencies, ESM + CommonJS, built-in TypeScript types, bail actually stops retries, AbortSignal + shouldRetry support. Drop-in for async-retry.

Readme

@bybrave/async-retry2

Maintained fork of async-retry — retrying made simple, easy, and async.

Same API, zero runtime dependencies (node-retry is vendored in), dual ESM + CommonJS, built-in TypeScript types, and a bail() that actually stops retrying.

Install

npm install @bybrave/async-retry2

Usage

import retry from '@bybrave/async-retry2';

await retry(
  async (bail, attempt) => {
    const res = await fetch('https://example.com');
    if (res.status === 403) {
      bail(new Error('Unauthorized')); // stops retrying immediately
      return;
    }
    return res.text();
  },
  { retries: 5 }
);

CommonJS works too — require returns the function directly:

const retry = require('@bybrave/async-retry2');

The supplied function receives (bail, attempt): call bail(error) to abort retrying, attempt is the 1-based attempt number.

Options

Passed through to node-retry, plus fork additions:

| Option | Default | Effect | |---|---|---| | retries | 10 | Maximum number of retries. | | factor | 2 | Exponential backoff factor. | | minTimeout | 1000 | Milliseconds before the first retry. | | maxTimeout | Infinity | Maximum milliseconds between retries. | | randomize | true | Multiply timeouts by a random 12 factor. | | onRetry | — | (error, attempt) => void \| Promise<void> after each failed attempt. May be async. | | shouldRetry | — | (error) => boolean — return false to stop retrying this error. (fork, #51) | | signal | — | AbortSignal to abort the whole operation, e.g. AbortSignal.timeout(5000). (fork, #73) |

What's fixed vs [email protected]

| Issue | Fix | |---|---| | #69 | bail() now actually stops the operation — no further attempts run and the retrier function is never called again after bail. Previously bail only rejected the promise while retries kept firing. | | #103 | Ships as native ESM with a CommonJS build via the exports map — no more (0 , async_retry_1.retry) is not a function. import and require both work. | | #110, #54 | Built-in TypeScript types (no separate @types/async-retry needed), including the attempt parameter. | | #51 | New shouldRetry(error) option to decide per-error whether to keep retrying. | | #43 | onRetry may be async; a rejection from it is swallowed instead of becoming an unhandled rejection. | | #73 | New signal option (AbortSignal) to time out or cancel the entire retry operation. | | — | Zero runtime dependencies — retry is vendored and maintained in-tree. |

Migration from async-retry

Drop-in — replace the import:

- const retry = require('async-retry');
+ const retry = require('@bybrave/async-retry2');

The retry/backoff behaviour is unchanged. The one intentional behaviour change is #69: after you call bail(), the function is no longer retried (this is what most people already expected).

Support

If this package saves you time, you can support maintenance:

Ko-fi Bitcoin

Bitcoin (BTC): bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q

License

MIT. Copyright © Vercel, Inc.; vendored node-retry © Tim Koschützki, Felix Geisendörfer; fork © bybrave.