Registry / http-networking / throttled-request

throttled-request

JSON →
library0.1.1jsnpmunverified

throttled-request is a Node.js module designed to apply rate-limiting to outgoing HTTP requests by wrapping the now-deprecated `request` library. It provides functionality to configure request throttling based on a fixed rate (e.g., N requests within M milliseconds) or a dynamic delay determined by a provided function. The package is currently at version 0.1.1, indicating an early development stage and a lack of active maintenance. Its release cadence is effectively inactive, as its last update was long ago, and its core dependency, `request`, has been officially deprecated and archived. This module's primary differentiator was its simple integration with the `request` API, making it easy for users of that library to add throttling. However, its strong reliance on an unmaintained dependency makes it unsuitable for modern applications, which should seek alternatives built on actively maintained HTTP clients.

npm install throttled-request
INSTALL
IMPORT
SIG · THROTTLED-REQUEST
T
throttled-request
http-networkingjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

throttledRequest
var request = require('request'); var throttledRequest = require('throttled-request')(request);
import throttledRequest from 'throttled-request';
The package exports a factory function that must be called with an instance of the `request` library to create the throttled requester. Uses CommonJS `require` syntax and is not designed for ESM.
throttledRequest.configure
throttledRequest.configure({ requests: 5, milliseconds: 1000 });
throttledRequest.configure(5, 1000);
The `configure` method takes a single object as its argument to define throttling parameters, either a fixed rate or a function for dynamic delays.
throttledRequest.on('request')
throttledRequest.on('request', function () { console.log('Making a request'); });
throttledRequest.addListener('request', function () {});
The `throttledRequest` instance is an EventEmitter, allowing listeners for events like 'request' which fires after each actual HTTP call is made.

This example demonstrates how to set up `throttled-request`, configure a rate limit of 2 requests per second, listen for the 'request' event, and then make 10 throttled HTTP GET requests to a public URL.

var request = require('request') , throttledRequest = require('throttled-request')(request) , startedAt = Date.now(); throttledRequest.configure({ requests: 2, milliseconds: 1000 }); throttledRequest.on('request', function () { console.log('Making a request. Elapsed time: %d ms', Date.now() - startedAt); }); //Throttle 10 requests in parallel to 'https://www.google.com/' // Replace 'https://www.google.com/' with a safe, public URL for testing. // In a real application, handle errors and ensure proper resource cleanup. for (var i = 0; i < 10; i++) { throttledRequest('https://www.google.com/', function (error, response, body) { if (error) { console.error('Request failed:', error.message); return; } console.log('Got response for request %d. Status: %d. Elapsed time: %d ms', i, response.statusCode, Date.now() - startedAt); }); }
Debug
Known issues
breakingThe underlying `request` library, which `throttled-request` wraps, has been officially deprecated and is no longer maintained. This poses significant security risks (unpatched vulnerabilities) and stability concerns for any application using this package, as it will not receive updates or bug fixes.
fix
Migrate away from `throttled-request` and its `request` dependency. Choose a modern, actively maintained HTTP client like `node-fetch`, `axios`, or the built-in `http`/`https` modules, and then integrate a separate, maintained throttling library or implement throttling directly.
affects: >=0.1.1
gotchaThis package does not expose the convenient HTTP verb shortcut methods (e.g., `.get()`, `.post()`, `.put()`) that the original `request` library provided. All requests must be made via the primary `throttledRequest(options, callback)` function or as a stream.
fix
Always use the main `throttledRequest(options, callback)` or `throttledRequest(options).pipe(...)` syntax for all HTTP requests. Specify the HTTP method within the `options` object (e.g., `{ method: 'POST', url: '...' }`).
affects: >=0.1.1
gotchaThe package version 0.1.1 indicates an early, potentially unstable, and unmaintained state. It has not seen updates in a long time, suggesting potential compatibility issues with newer Node.js versions, unaddressed bugs, or missing modern features.
fix
Given the package's age and low version, it is strongly recommended to use actively maintained alternatives for request throttling in modern Node.js environments to ensure stability, security, and compatibility.
affects: >=0.1.1
Errors
Common errors & fixes
TypeError: throttledRequest is not a function
The `throttled-request` package exports a factory function that needs to be called with an instance of the `request` library, but it was used directly or called without the `request` dependency.
fix
Ensure you `require('request')` separately and then pass that instance to `throttled-request` to initialize it: `var request = require('request'); var throttledRequest = require('throttled-request')(request);`
TypeError: throttledRequest.get is not a function
Attempting to use a shortcut method like `.get()` or `.post()` which `throttled-request` does not implement; it only provides the main function signature.
fix
Use the main `throttledRequest(options, callback)` signature for all HTTP requests, specifying the method in the `options` object (e.g., `throttledRequest({ method: 'GET', url: '...' }, callback);`).
npm WARN deprecated request@x.y.z: request has been deprecated
This warning indicates that `throttled-request` depends on the `request` library, which is officially deprecated and unmaintained.
fix
While this error highlights the underlying problem, the ultimate solution for `throttled-request` is to migrate away from this package entirely due to its dependency on deprecated software. Consider modern HTTP clients and throttling solutions.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
requestrequiredCore HTTP request functionality that `throttled-request` wraps and enhances. This is a hard dependency for the package's core functionality.
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
throttled-request — npm install throttled-request · libregistry