Installation
npm i resilience-pipelinepnpm add resilience-pipelineyarn add resilience-pipelinebun add resilience-pipelineNo runtime dependencies. TypeScript types are included.
Runtimes
Section titled “Runtimes”| 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) |
ESM and CommonJS
Section titled “ESM and CommonJS”Both builds ship with their own type declarations, resolved through exports:
import { ResiliencePipelineBuilder } from 'resilience-pipeline';const { ResiliencePipelineBuilder } = require('resilience-pipeline');The package is marked "sideEffects": false, so bundlers drop every strategy you don’t import. See
Bundle size.
Entry points
Section titled “Entry points”Integrations live in subpaths, so the main entry never pulls in framework code.
| Import | Contents |
|---|---|
resilience-pipeline |
Builders, every strategy, outcomes, errors, registry, telemetry, batches, createStats |
resilience-pipeline/outcome |
Outcome helpers and error classes only, for code that just handles results |
resilience-pipeline/testing |
FakeTimeProvider |
resilience-pipeline/fetch |
createResilientFetch() |
resilience-pipeline/axios |
attachResilience() |
resilience-pipeline/http |
Express/Connect and Hono middleware, describeResilienceError() |
resilience-pipeline/fastify |
Fastify plugin |
resilience-pipeline/koa |
Koa middleware |
resilience-pipeline/nestjs |
NestJS module and decorators |
resilience-pipeline/redis |
Redis stores and limiters |
resilience-pipeline/adapters |
rate-limiter-flexible |
resilience-pipeline/otel |
OpenTelemetry |
resilience-pipeline/prometheus |
Prometheus |
resilience-pipeline/hystrix |
Hystrix dashboard stream |
Optional peer dependencies
Section titled “Optional peer dependencies”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).
CDN (script tag)
Section titled “CDN (script tag)”A minified IIFE build of the main entry is published at dist/browser/resilience-pipeline.min.js. It exposes
window.resiliencePipeline:
<script src="https://unpkg.com/resilience-pipeline"></script><script> const { retry } = window.resiliencePipeline; retry(() => fetch('/api/health'), { maxRetryAttempts: 3, delay: 500 }).then(console.log);</script>https://cdn.jsdelivr.net/npm/resilience-pipeline serves the same file.