Minimalistic drop-in replacement for node-fetch with built-in retry and timeout support. Current version 1.2.1. It distinguishes itself from alternatives by configuring retries via attempt count (not total duration), supporting per-request timeouts via AbortController, and allowing dynamic option changes on each retry via beforeRetry callback. Offers flexible retry logic using a callback based on HTTP response status. Active maintenance.
npm install node-fetch-retry-timeoutNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic usage with retry, timeout, and beforeRetry callback. Shows drop-in replacement for node-fetch with additional options.
Explicitly set redirect: 'follow' in options if you need automatic redirect following.
Set timeout option to override (0 disables timeout).
Pass retryOnHttpResponse: false to disable automatic retry on 5xx status codes.
Check retryNum === 0 for the first retry attempt; increment logic accordingly.
Check if error has response property before accessing status codes.
Install node-fetch@2 or use dynamic import: const fetch = (...args) => import('node-fetch-retry-timeout').then(m => m.default(...args))Use import fetch from 'node-fetch-retry-timeout' (ESM) or const fetch = require('node-fetch-retry-timeout') (CJS).Increase timeout value or implement retry logic to handle timeouts gracefully.
Install node-fetch (v2) as a dependency and ensure it is available.