Playground
This page runs the actual resilience-pipeline library in your browser. Tune the flaky dependency on the left, switch strategies on and off, press Start and watch each request in the timeline. Statistics come from createStatsover a 10-second rolling window. Timing is real; the same seed replays the same sequence of failures and latencies.
Changing a strategy rebuilds the pipeline (breaker state starts closed again).
Circuit:closed0 in flight
Circuit closed.
–OK incl. fallback (10 s)
–p50 latency
–p99 latency
0Retries
0Timeouts
0Rejections
0Fallbacks
0Total calls
Timeline (last 240 requests)
- success
- recovered (retry / hedge)
- cache hit
- fallback
- timeout
- rejected (circuit / bulkhead)
- failed
| # | Result | Attempts | Latency |
|---|
import { PipelineBuilder, fallbackStrategy, retryStrategy, circuitBreakerStrategy, timeoutStrategy } from 'resilience-pipeline';
// Strategies run in the order they are added: the first is the outermost.
const pipeline = new PipelineBuilder<User>()
.add(fallbackStrategy({ fallbackValue: cachedUser }))
.add(retryStrategy({ maxRetryAttempts: 3, backoffType: 'exponential', delay: 100, useJitter: true }))
.add(circuitBreakerStrategy({ failureRatio: 0.5, minimumThroughput: 10, samplingDuration: '10s', breakDuration: 5000 }))
.add(timeoutStrategy(500))
.build();
const user = await pipeline.execute(({ signal }) => fetchUser(42, { signal }));