I Built a Retry Library Because I Kept Losing Failed API Calls
Description and use
smart-retry automatically retries Axios/Fetch requests, logs detailed failure data, and lets you inspect or replay failed requests.
Problem
Existing retry libraries only retry a function and throw on failure, leaving no record of the failed request, making debugging hard.
Outcome
The library provides automatic retries for network errors, timeouts, 429s, and 5xx responses, logs detailed failure information to disk, and exposes a manager to inspect and replay failed requests.
Workflow
- 1. Install the library:
npm install @aubaid/smart-retry - 2. Create a retry-enabled client:
const client = createAxiosRetry({maxRetries:5, delay:2000, backoff:'exponential'}); - 3. Make API calls through the client (e.g.,
await client.get('https://api.example.com/users')). - 4. If retries exhaust, the library logs the failed request to a file.
- 5. Retrieve logged failures via
client.getRetryManager().getFailedRequests()and view log file path withgetLogFilePath().
Evidence
Drop-in Axios and Fetch clients, not just a generic wrapper function
Automatic failure logging when a request exhausts all retries, it gets written to disk with its URL, method, headers, body, and error
- Record date: 2026-09-06T09:06:42.668Z