request-retry is a Node.js library designed to automatically re-attempt HTTP(S) requests that fail due to transient network errors or specific HTTP status codes like 5xx and 429 (Too Many Requests). It functions as a wrapper, providing a drop-in replacement API for the underlying HTTP client, but with added configurable retry logic including `maxAttempts`, `retryDelay`, and a customizable `retryStrategy`. The current stable version, 8.0.0, marks a significant shift, migrating its core dependency from the unmaintained `request` library to the more actively developed `postman-request` fork, addressing security concerns and ensuring continued functionality. This package is crucial for building robust network clients that can gracefully handle temporary service disruptions, simplifying the implementation of resilient communication patterns by abstracting away common retry mechanisms.
npm install requestretryVerified import paths — ran on the pinned version, not inferred.
Demonstrates a basic promise-based HTTP GET request using request-retry, configured to retry on 5xx errors or network issues with a delay.
Ensure `postman-request` is installed in your project: `npm install postman-request`
For new projects, consider modern alternatives to the `request` API if deep integration or long-term stability with the underlying HTTP client is critical, or rely on `postman-request`'s continued maintenance.
Install the peer dependency: `npm install postman-request`.
Run `npm install postman-request` to install the required HTTP client.
Use CommonJS `require` syntax: `const request = require('requestretry');` Ensure your project's module type is correctly configured if using ESM.Upgrade `request-retry` to version 8.0.0 or higher: `npm install requestretry@latest`. Also, ensure `postman-request` is installed as a peer dependency.