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

firefly-limiter

v1.0.3

Published

Resilience harness for TypeScript: retries, timeouts, circuit breakers, bulkheads and rate limits, composed as one policy.

Downloads

124,017

Readme

firefly-limiter

logo

Retries, timeouts, circuit breakers, bulkheads, rate limits and hedging for the outgoing calls of one process, for setups without a service mesh.

npm install firefly-limiter

Node 22 or later, ESM only. CI runs Node 22 and 24 on Linux, Windows and macOS. No runtime dependencies, and nothing runs at import time.

Example

Describe the upstream once, next to the client that calls it:

import { Dependency, exponential, retryAnything } from "firefly-limiter";

export const rates = new Dependency({
	name: "rates",
	attempts: 3,
	backoff: exponential({ base: 200, max: 5_000 }),
	shouldRetry: retryAnything,
	deadline: 2_000,
	breaker: { threshold: 5, resetAfter: 30_000 },
});

Every field is required. There are no default numbers. Then call through it. Each attempt gets an AbortSignal that the deadline aborts:

const today = await rates.run((signal) => readRates(signal), {
	share: "today",         // concurrent callers with this key make one request
	fallback: () => cached, // answer here if every attempt failed
});

When the attempts run out, your last error is rethrown unchanged. Firefly's own errors (TimeoutError, CircuitOpenError, BulkheadFullError, RateLimitError) are only for its refusals.

To put the same policy under an HTTP client instead, wrap its fetch:

import { retryableTransportError, transport } from "firefly-limiter/http";

const api = new ApiClient({
	baseUrl: "https://api.example.com/v1",
	transport: transport(fetch, rates.policy),
});

health() returns the current state without changing it, so a health endpoint can call it:

app.get("/health", () => rates.health());
// { name: "rates", circuit: "closed", failures: 0, inFlight: 0, queued: 0 }

Not included

  • State shared across processes. Counts live in one process, so 20 replicas means 20 breakers. See Boundaries.
  • Use behind a service mesh. If Envoy or Istio already retries, the two layers of retries multiply.
  • Protecting a server from its callers. This is for calls you make.
  • I/O, caching, logging and metrics. You pass the call in, caching is Repletes, and onEvent gives you every decision for your own metrics.

Known quirks

  • Inside a transport a 429 is a resolved Response, not an HttpError, so a shouldRetry that checks for HttpError never matches. Use retryableTransportError for a dependency you hand to transport.
  • Create each Dependency or CircuitBreaker once and share it. One created inside a client factory counts only that client's calls, and one created per request never trips.
  • stack throws a TypeError when policies are in an order that cannot work, for example timeout outside retry. Dependency builds the order for you.

Guides

Full API reference: https://smiduweorc.github.io/firefly/

License

MIT