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/promise-retry2

v3.0.1

Published

Maintained promise-retry fork: zero runtime dependencies, ESM + CommonJS, built-in TypeScript types, and the retry operation exposed for reset/stop. Drop-in for promise-retry.

Readme

@bybrave/promise-retry2

Maintained, drop-in fork of promise-retry — retries a function that returns a promise, with exponential backoff.

The original has had no release since 2020 (2.0.1) while still pulling ~188M downloads/month, with types living in a separate @types/promise-retry (~1.1M/month) and two runtime dependencies. This fork bundles the TypeScript types, drops to zero runtime dependencies, ships ESM + CommonJS, and exposes the retry operation so you can reset the backoff or stop pending retries. The API is unchanged.

npm install @bybrave/promise-retry2
const promiseRetry = require('@bybrave/promise-retry2'); // CommonJS
import promiseRetry from '@bybrave/promise-retry2';       // ESM

Usage

promiseRetry((retry, number) => {
  return doSomething().catch(retry);
}, {retries: 5});

fn is called with (retry, attemptNumber, operation). Call retry(err) to trigger another attempt; it always throws, so returning/throwing it ends the current try. When the retries run out, the promise rejects with the last error. Options are the same as the underlying retry module (retries, factor, minTimeout, maxTimeout, randomize, forever). The alternate (options, fn) argument order also works.

What's fixed

| Issue | Problem | Fix | |---|---|---| | — | Types shipped separately as @types/promise-retry. | Types are bundled — no extra install. | | — | Two runtime dependencies (retry, err-code). | Zero runtime dependencies — both vendored in. | | — | CommonJS only, no import. | Dual ESM + CommonJS build. | | #25, #32 | No way to reset the backoff when a dependency recovers early, or to inspect/stop the operation. | The retry operation is exposed as the third argument — call operation.reset(), operation.stop(), or operation.getTimeout(). | | #37 | No CHANGELOG / release notes. | Releases are documented. |

Exposing the operation

promiseRetry((retry, number, operation) => {
  return call().catch((err) => {
    // When the network is back, forget the accumulated backoff delay:
    if (isBackOnline()) operation.reset();
    retry(err);
  });
}, {retries: 10});

operation.getTimeout() returns the ms until the next scheduled attempt — handy for logging "retrying in 16s".

Notes on behavior (unchanged, by design)

  • Memory with huge retries (#20): the underlying retry module precomputes a timeouts array of length retries, so memory grows O(retries). For effectively-infinite retries use forever: true (or a modest retries with a large maxTimeout) instead of a giant number.
  • retries: 0 (#8) means "no retries", not "retry forever" — use forever: true for that.
  • After calling retry(err), don't throw again in the same tick without returning it — return retry(err) (#14).

Migration from promise-retry

Replace the dependency and the import, and remove @types/promise-retry from your devDependencies — the types are built in. Everything behaves the same, plus the fixes above.

Support

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

Ko-fi Bitcoin

Bitcoin (BTC): bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q

Credits & license

MIT, same as the original — see LICENSE. Based on node-promise-retry by IndigoUnited.