Changelog
0.1.0 (unreleased)
Section titled “0.1.0 (unreleased)”The first release. Everything below ships in it.
ResiliencePipelineBuilderwith Polly v8’s API and defaults, plusPipelineBuilder+xStrategy()factories for tree-shaken bundles.execute,executeOutcome,settle(typed errors),executeStream(protects everything up to the first chunk; fallbacks may answer with a value or a stream; hedged attempts never mix streams) andwrap(fn).ResilienceContextwithsignal,operationKey, typedproperties(ResiliencePropertyKey),attemptNumber(0-based) andidempotent.- One-liners without a pipeline:
retry(fn, options),withTimeout(fn, duration),NonRetryableError. - Deadline propagation: a pipeline executed inside another inherits its signal.
getResilienceSignal()/getResilienceContext()from anywhere in the call. - Durations as milliseconds or strings (
'250ms'…'2w'); delays past setTimeout’s ~24.8-day limit are chained. - Kill switch (
disable()/enable()),describe(),getStrategy(),dispose(). ResiliencePipelineRegistrywith livereload(),circuitBreakers()andlimiters().- Runs on Node.js ≥ 20.16, Bun, Deno, Cloudflare Workers and browsers. ESM, CommonJS and a script-tag build. Zero dependencies.
Strategies
Section titled “Strategies”- Retry: constant / linear / exponential backoff,
factor, jitter (true,'full','equal'),maxDelay,delayGenerator,Retry-Afterhonoured,initialDelay,maxRetryTime,shouldConsumeRetry,onFailedAttempt,onRetryExhausted, sharedRetryBudget. - Timeout: aggressive by default,
cooperative(Polly’s behaviour) andkeepLateResultas options. - Circuit breaker: time or count window,
consecutiveFailures,minimumRps,halfOpenMaxCalls,halfOpenSuccessThreshold,halfOpenMaxWait,warmUpDuration, pluggablebreakerpolicy, manual isolation (stacking),trip()/reset(), snapshots with the rolling window,circuitHealthCheck()andsharedCircuitState()extensions. - Fallback:
fallbackAction/fallbackValue,addFallbackOn(codes),addMapError,addStaleFallback. - Hedging: latency, parallel and fallback modes,
actionGenerator, per-attempt property copies. - Concurrency: bulkhead with FIFO queue,
queueTimeout, priority and overflow policies; adaptive concurrency (gradient2, vegas, aimd). - Rate limiting: token bucket, fixed and sliding window, partitioned (per key), bursty limiter, weights, fair waiting, block / penalty / reward, allow / deny lists, insurance limiter, even spacing /
minTime, snapshot / restore,getRateLimitInfo(). - Cache and coalesce: TTL, stale-if-error, single-flight, pluggable
CacheStore. - Lock: leases with renewal and fencing tokens, pluggable
LockStore. - Chaos: fault, outcome, latency and behavior injection with Polly’s event names,
weighted()generators,setGlobalChaos(). - Batches:
all,allSettled,map(with concurrency),waitFor, andcreateBatcher()for request batching.
Errors
Section titled “Errors”- Every strategy error extends
ExecutionRejectedErrorwith a stablecode, asourceandtoJSON(). - Guards that work across duplicate package copies:
isResilienceError,isTimeoutError,isBrokenCircuitError,isRateLimitError,isRejection. Outcome.match/try/all/partition/unwrap/unwrapErr,registerResultAdapter()for other Result types, and theresilience-pipeline/outcomesubpath.describeResilienceError()/httpStatusFor()(504 / 429 / 503 / 409 / 403).
Integrations (subpath exports)
Section titled “Integrations (subpath exports)”/fetch:createResilientFetch()with per-host breakers and per-request overrides./axios:attachResilience()./http(Express, Connect, Hono),/fastify,/koa: request deadlines, load shedding, per-client rate limits withRateLimit-*headers./nestjs:ResilienceModule.forRoot/forRootAsyncand method decorators for providers./redis: cache, lock (atomic fencing), rate limiter and shared circuit state, tested on Redis Cluster./adapters: rate-limiter-flexible./otel,/prometheus,createStats(),/hystrix;onTelemetry(),diagnostics_channel,instrument()./testing:FakeTimeProvider.- The
@resilientmethod decorator (standard and legacy decorators).