Skip to main content

Resilience

Lightweight resilience toolkit for JavaScript/TypeScript: retries, timeouts, backoff, circuit breaker, and metrics hooks—simple to wrap any function.

Key Features

Retry Logic

Configure automatic retries with custom retry conditions to handle transient failures gracefully.

Smart Timeouts

Set timeout limits with abort signal support to prevent hanging operations.

Backoff Strategies

Choose between fixed or exponential backoff with optional jitter to reduce load spikes.

Circuit Breaker

Implement circuit breaker patterns to prevent cascade failures in distributed systems.

Metrics & Observability

Track execution metrics with customizable hooks for monitoring and debugging.

TypeScript-First

Full type safety and IntelliSense support with comprehensive TypeScript definitions.

Quick Start

Get up and running with Resilience in just a few lines of code.
npm install @oldwhisper/resilience
import { withResilience } from "@oldwhisper/resilience";

const resilientFetch = withResilience(fetchData, {
  retries: 3,
  timeoutMs: 5000,
  backoff: { type: "exponential", baseDelayMs: 100, maxDelayMs: 2000 }
});

await resilientFetch();

Explore the Docs

Quick Start

Get started with Resilience in minutes with our step-by-step guide.

Core Concepts

Learn about retries, timeouts, backoff strategies, and circuit breakers.

API Reference

Explore the complete API documentation and configuration options.

Examples

See real-world examples of HTTP retries, database operations, and more.

Why Resilience?

Building reliable distributed systems requires handling failures gracefully. Resilience provides a simple, lightweight toolkit to make your functions more robust:
  • Zero Dependencies: Minimal footprint with no external dependencies
  • Framework Agnostic: Works with any JavaScript/TypeScript framework
  • Production Ready: Battle-tested patterns for real-world applications
  • Developer Friendly: Intuitive API that wraps any function with minimal boilerplate
Resilience is designed to be simple yet powerful. Wrap any function with resilience features without changing its signature or behavior.

Build docs developers (and LLMs) love