Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Promises
  3. p-retry

p-retry

MITJavaScriptv8.0.1

A promise retry library with exponential backoff, custom retry strategies, and abort functionality.

GitHubGitHub
1.0k stars88 forks0 contributors

What is p-retry?

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.

Target Audience

Node.js developers building resilient applications that interact with external APIs, databases, or services where transient failures are common.

Value Proposition

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.

Overview

Retry a promise-returning or async function

Use Cases

Best For

  • Retrying failed HTTP requests to external APIs with exponential backoff
  • Handling temporary database connection failures in Node.js applications
  • Implementing resilient file upload operations with custom retry logic
  • Building CLI tools that need to gracefully handle intermittent network issues
  • Adding retry mechanisms to third-party API client libraries
  • Creating robust background job processors that survive transient errors

Not Ideal For

  • Applications requiring circuit breaker patterns to prevent service overload during sustained failures
  • Simple scripts where a basic retry loop with fixed delays would suffice without library overhead
  • Real-time systems where accumulating exponential backoff delays could violate strict latency requirements
  • Projects using HTTP clients like Axios with built-in retry mechanisms, to avoid redundancy

Pros & Cons

Pros

Configurable Exponential Backoff

Allows adjustable delays between retries using factors and timeouts, such as minTimeout and maxTimeout, to avoid overwhelming services as detailed in the options.

Fine-grained Retry Control

Provides callbacks like shouldRetry and shouldConsumeRetry for custom logic, enabling precise error handling and retry budget management based on context.

Integrated Abort Mechanism

Supports AbortSignal for clean cancellation, useful for user-initiated stops or handling process signals like SIGINT, as shown in the signal option examples.

Intelligent Network Error Handling

Automatically retries on network-related TypeErrors while aborting on others, leveraging fetch specification best practices to distinguish transient failures.

Cons

Automatic Abort on Errors

Non-network TypeErrors always abort retries without allowing overrides via shouldRetry in some cases, which can be too restrictive for custom error scenarios.

No Built-in Circuit Breaking

Lacks features like circuit breakers to halt retries during outages, requiring additional libraries for comprehensive fault tolerance beyond simple retries.

Testing Requires Timer Mocking

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.

Frequently Asked Questions

Quick Stats

Stars1,037
Forks88
Contributors0
Open Issues1
Last commit1 month ago
CreatedSince 2016

Tags

#async-await#utility-library#error-handling#api-client#exponential-backoff#node-js#resiliency

Built With

N
Node.js

Included in

Promises1.7k
Auto-fetched 1 day ago

Related Projects

p-queuep-queue

Promise queue with concurrency control

Stars4,298
Forks227
Last commit6 days ago
p-limitp-limit

Run multiple promise-returning & async functions with limited concurrency

Stars2,934
Forks146
Last commit1 month ago
p-mapp-map

Map over promises concurrently

Stars1,517
Forks87
Last commit12 days ago
pifypify

Promisify a callback-style function

Stars1,502
Forks72
Last commit1 month ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub