A promise retry library with exponential backoff, custom retry strategies, and abort functionality.
p-retry is a Node.js library that automatically retries failed promise-based operations with configurable strategies. It solves the problem of transient failures in network requests, API calls, and other async operations by implementing exponential backoff and custom retry logic to improve application reliability.
Node.js developers building resilient applications that interact with external APIs, databases, or services where transient failures are common.
Developers choose p-retry for its clean API, flexible configuration, and intelligent error handling—particularly its ability to distinguish network errors from fatal TypeErrors and provide fine-grained control over retry behavior through multiple callback hooks.
Retry a promise-returning or async function
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows adjustable delays between retries using factors and timeouts, such as minTimeout and maxTimeout, to avoid overwhelming services as detailed in the options.
Provides callbacks like shouldRetry and shouldConsumeRetry for custom logic, enabling precise error handling and retry budget management based on context.
Supports AbortSignal for clean cancellation, useful for user-initiated stops or handling process signals like SIGINT, as shown in the signal option examples.
Automatically retries on network-related TypeErrors while aborting on others, leveraging fetch specification best practices to distinguish transient failures.
Non-network TypeErrors always abort retries without allowing overrides via shouldRetry in some cases, which can be too restrictive for custom error scenarios.
Lacks features like circuit breakers to halt retries during outages, requiring additional libraries for comprehensive fault tolerance beyond simple retries.
Relies on global setTimeout, making unit tests non-deterministic without mocking timers, as acknowledged in the FAQ about using Node.js test tools or sinon.