The `retry-promise` package (version 1.0.0), last published in November 2015, provides a small utility function for automatically retrying promise-returning operations. It was explicitly designed to work with Bluebird Promises and implements a basic retry mechanism with configurable maximum attempts (`opts.max`) and a linear backoff strategy. The delay between retries is calculated as `attempt_number * opts.backoff`, meaning each subsequent retry waits proportionally longer. Given its age and lack of updates for nearly a decade, this package is considered abandoned. It lacks support for modern JavaScript features like native Promises or ES Modules and does not offer advanced retry strategies (e.g., jitter, custom error predicates) found in more actively maintained alternatives such as `p-retry` or `ts-retry-promise`. For new projects, developers should consider these contemporary libraries over `retry-promise`.
npm install retry-promiseVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `retry-promise` to retry a function that returns a Promise until it resolves. It includes a mock `User` service that simulates transient failures, showcasing the retry logic and linear backoff strategy.
Consider migrating to actively maintained alternatives like `p-retry` or `ts-retry-promise` for modern applications.
Ensure `bluebird` is installed and used if encountering unexpected Promise-related issues, or use a modern retry library that supports native Promises by default.
Be aware of the linear backoff behavior. If exponential backoff or more sophisticated strategies (e.g., jitter, custom predicates for retrying specific errors) are required, consider alternative retry libraries.
Ensure that Bluebird is being used or that the function passed to `retry` explicitly returns a Bluebird Promise. If migrating is not an option, you might need to manually adapt Bluebird into your project.
Modify the function passed to `retry` to ensure it always returns a Promise, regardless of its execution path.