Registry / testing / upgraded-fetch-timeout

upgraded-fetch-timeout

JSON →
library0.0.3jsnpmunverified

A lightweight HTTP/S fetch wrapper that adds configurable timeout support with custom error messages. Current version 0.0.3 (last release unknown, appears low maintenance). Requires node-fetch as peer dependency for Node.js environments, but attempts to use window.fetch when available. Differentiates from similar packages by allowing a custom error string on timeout, and support for both ES5/CommonJS and ES6/ESM imports. The package is a fork of the original fetch-timeout with minor updates but no active development.

npm install upgraded-fetch-timeout
INSTALL
IMPORT
SIG · UPGRADED-FETCH-TIM
U
upgraded-fetch-timeout
testingjavascriptv0.0.3
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.

fetchTimeout
import fetchTimeout from 'upgraded-fetch-timeout'
const fetchTimeout = require('upgraded-fetch-timeout')
Supports both ESM and CJS. Default import only; no named export.
require
const fetchTimeout = require('upgraded-fetch-timeout')
import { fetchTimeout } from 'upgraded-fetch-timeout'
CJS users must use require; named import does not work.
fetchTimeout
window.fetchTimeout = require('upgraded-fetch-timeout')
import fetchTimeout from 'upgraded-fetch-timeout'; window.fetchTimeout = fetchTimeout;
In browser environments, ensure you assign to window if needed.

Demonstrates default import and usage with custom timeout (5000ms) and custom error message.

import fetchTimeout from 'upgraded-fetch-timeout'; fetchTimeout('https://api.github.com/', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, }, 5000, 'My custom timeout error') .then(res => { if (res.status !== 200) throw new Error('Status not OK'); return res.json(); }) .then(json => console.log(json)) .catch(err => console.log('Error:', err));
Debug
Known issues
gotchaThe package tries window.fetch first — in Node.js it silently falls back to node-fetch if available, else fails.
fix
Ensure window.fetch is defined in browser or install node-fetch peer dependency in Node.
affects: <=0.0.3
deprecatedOriginal fetch-timeout is no longer maintained; this fork may have limited updates.
fix
Consider using native AbortController timeout for modern Node (>=15) and browsers.
affects: >=0.0.1
gotchaThe timeout value is in milliseconds; passing a non-number will cause unexpected behavior.
fix
Always pass a positive integer for timeout.
affects: all
gotchaThe custom error argument is string only; if you need an Error object, throw it after catch.
fix
Handle errors manually in the .catch block instead of relying on the string error.
affects: all
Errors
Common errors & fixes
ReferenceError: fetch is not defined
Missing node-fetch peer dependency in Node.js environment without global fetch.
fix
npm install node-fetch@^2.6.6
TypeError: fetchTimeout is not a function
Using named import instead of default import.
fix
Use 'import fetchTimeout from 'upgraded-fetch-timeout'' (no curly braces).
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
node-fetchoptionalpeer dependency for Node.js environments where window.fetch is unavailable
Agent activity
6 hits · last 30 days
node
6
Resources
upgraded-fetch-timeout — npm install upgraded-fetch-timeout · libregistry