Registry / devops / node-fetch-backoff

node-fetch-backoff

JSON →
library0.2.0jsnpmunverified

A wrapper around node-fetch that adds automatic retries with exponential backoff. Version 0.2.0 is the latest. It allows configurable delay, retry count, custom success checks, and error/response retry conditions. Useful for handling transient network failures in Node.js HTTP clients.

npm install node-fetch-backoff
INSTALL
IMPORT
SIG · NODE-FETCH-BACKOFF
N
node-fetch-backoff
devopsjavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import nfbFactory from 'node-fetch-backoff'
import { nfbFactory } from 'node-fetch-backoff'
The package exports a factory function as the default export.
default
const nfbFactory = require('node-fetch-backoff')
const { nfbFactory } = require('node-fetch-backoff')
CommonJS require returns the factory directly.
types
import type { FetchOptions } from 'node-fetch-backoff'
TypeScript typings may be available; check the package for exported types.

Shows how to import the factory, configure retries with exponential backoff, and make a fetch request.

import nfbFactory from 'node-fetch-backoff'; const fetch = nfbFactory({ delay: 1000, retries: 3, shouldRetryError: (err) => err.code === 'ECONNRESET', }); async function main() { try { const res = await fetch('https://api.example.com/data'); console.log(await res.json()); } catch (err) { console.error('Request failed after retries', err); } } main();
Debug
Known issues
deprecatednode-fetch is deprecated in favor of global fetch (Node.js 18+). This package may not receive updates.
fix
Consider using native fetch with a retry wrapper or a maintained alternative.
affects: >=0.2.0
gotchaDefault `isOK` checks `resp.ok`; non-2xx responses are treated as failures and retried.
fix
Override `isOK` if you want to accept certain error statuses.
affects: >=0.0.0
gotchaDefault `shouldRetryResponse` always returns true, so all non-OK responses are retried up to `retries` times.
fix
Set `shouldRetryResponse` to a function that returns false for unwanted retries.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: nfbFactory is not a function
Using named import instead of default import in ESM.
fix
Use `import nfbFactory from 'node-fetch-backoff'` or `const nfbFactory = require('node-fetch-backoff')`.
Cannot find module 'node-fetch'
The package tries to require 'node-fetch' if none is provided via options.fetch.
fix
Install node-fetch: `npm install node-fetch` or provide your own fetch implementation.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
node-fetchoptionalUsed as the underlying fetch implementation if not provided
Agent activity
4 hits · last 30 days
node
4
Resources
node-fetch-backoff — npm install node-fetch-backoff · libregistry