Skip to content
Buy me a coffee

Installation

Terminal window
npm i @ylcnfrht/resilience

No runtime dependencies. TypeScript types are included.

Runtime Support
Node.js ≥ 20.16 (engines field)
Bun, Deno Supported
Cloudflare Workers Supported. Enable nodejs_compat for deadline propagation
Browsers Supported, with two features degraded (see Runtimes)

Both builds ship with their own type declarations, resolved through exports:

import { ResiliencePipelineBuilder } from '@ylcnfrht/resilience';

The package is marked "sideEffects": false, so bundlers drop every strategy you don’t import. See Bundle size.

Integrations live in subpaths, so the main entry never pulls in framework code.

Import Contents
@ylcnfrht/resilience Builders, every strategy, outcomes, errors, registry, telemetry, batches, createStats
@ylcnfrht/resilience/outcome Outcome helpers and error classes only, for code that just handles results
@ylcnfrht/resilience/testing FakeTimeProvider
@ylcnfrht/resilience/fetch createResilientFetch()
@ylcnfrht/resilience/axios attachResilience()
@ylcnfrht/resilience/http Express/Connect and Hono middleware, describeResilienceError()
@ylcnfrht/resilience/fastify Fastify plugin
@ylcnfrht/resilience/koa Koa middleware
@ylcnfrht/resilience/nestjs NestJS module and decorators
@ylcnfrht/resilience/redis Redis stores and limiters
@ylcnfrht/resilience/adapters rate-limiter-flexible
@ylcnfrht/resilience/otel OpenTelemetry
@ylcnfrht/resilience/prometheus Prometheus
@ylcnfrht/resilience/hystrix Hystrix dashboard stream

Install these only for the subpath that needs them. They are marked optional, so package managers don’t install or warn about them otherwise.

Peer Version Used by
@nestjs/common, @nestjs/core ≥ 10 /nestjs
@opentelemetry/api ^1.4.0 /otel
prom-client ≥ 14 /prometheus
axios ≥ 1.0.0 /axios
fastify ≥ 4 /fastify
koa ≥ 2 /koa

/redis and /adapters don’t declare peers: you pass in a client or store you already created (ioredis, node-redis, rate-limiter-flexible).

A minified IIFE build of the main entry is published at dist/browser/resilience.min.js. It exposes window.resilience:

<script src="https://unpkg.com/@ylcnfrht/resilience"></script>
<script>
const { retry } = window.resilience;
retry(() => fetch('/api/health'), { maxRetryAttempts: 3, delay: 500 }).then(console.log);
</script>

https://cdn.jsdelivr.net/npm/@ylcnfrht/resilience serves the same file.