What is Resilience?
Resilience is a lightweight toolkit that makes your JavaScript and TypeScript functions more robust and fault-tolerant. It provides a simple wrapper system that adds retry logic, timeouts, backoff strategies, circuit breakers, and observability hooks to any function. Unlike heavyweight resilience frameworks, Resilience is designed to be minimal, dependency-free, and easy to integrate into existing codebases.Key features
Retry with backoff
Automatically retry failed operations with configurable fixed or exponential backoff strategies
Timeouts
Set maximum execution time for operations to prevent hanging requests
Circuit breaker
Automatically stop calling failing services to give them time to recover
Observability hooks
Built-in lifecycle hooks for metrics collection and monitoring
Why Resilience?
Handle transient failures gracefully
Network requests, database queries, and external API calls can fail temporarily due to network issues, service overload, or rate limiting. Resilience automatically retries these operations with intelligent backoff strategies.Prevent cascading failures
When a downstream service fails, the circuit breaker pattern prevents your application from repeatedly calling it, giving the failing service time to recover and protecting your application from resource exhaustion.Zero dependencies
Resilience has no external dependencies and weighs just a few kilobytes, making it perfect for serverless functions, edge computing, and browser applications.Common use cases
- API clients: Retry failed HTTP requests with exponential backoff
- Database operations: Handle transient connection failures
- Microservices: Implement circuit breakers between services
- Background jobs: Add timeouts and retry logic to task processors
- Serverless functions: Make cloud functions more resilient to cold starts and network issues
Example
Here’s a quick example of wrapping a function with resilience features:Next steps
Quickstart
Get started with Resilience in under 5 minutes

