Registry / devops / limited-request-queue

limited-request-queue

JSON →
library5.1.0jsnpmunverified

A Node.js queue library for interactively managing concurrency and rate limiting of outbound HTTP requests. Version 5.1.0 stable, with a maintenance-focused release cadence. Key differentiators: per-host concurrency limiting via URL host grouping, pause/resume at any time, simple EventEmitter-based API, and options to ignore ports, protocols, and subdomains for host grouping. Unlike generic async queues, it is specifically designed for outbound requests with host-aware throttling.

npm install limited-request-queue
INSTALL
IMPORT
SIG · LIMITED-REQUEST-QU
L
limited-request-queue
devopsjavascriptv5.1.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.

RequestQueue
import RequestQueue, { END_EVENT, ITEM_EVENT } from 'limited-request-queue'
import { RequestQueue } from 'limited-request-queue'
RequestQueue is the default export, not a named export. Named exports include END_EVENT and ITEM_EVENT constants.
END_EVENT
import { END_EVENT } from 'limited-request-queue'
import { END_EVENT } from 'limited-request-queue' (correct) but confusion arises with default import
END_EVENT is a named export from the package. It is a constant string used for the event name.
ITEM_EVENT
import { ITEM_EVENT } from 'limited-request-queue'
const ITEM_EVENT = require('limited-request-queue').ITEM_EVENT
In CommonJS, destructure from the default export: const { default: RequestQueue, END_EVENT, ITEM_EVENT } = require('limited-request-queue')
RequestQueue (CommonJS)
const { default: RequestQueue, END_EVENT, ITEM_EVENT } = require('limited-request-queue')
const RequestQueue = require('limited-request-queue')
Because the package uses ESM source, the CommonJS wrapper exports the default under a 'default' key. Direct require gives an object with a default property.

Creates a queue with max 5 concurrent requests, enqueues three URLs, logs each fetch and completion.

import RequestQueue, { ITEM_EVENT, END_EVENT } from 'limited-request-queue'; const queue = new RequestQueue({ maxSockets: 5 }) .on(ITEM_EVENT, (url, data, done) => { console.log(`Fetching: ${url.href}`); fetch(url.href) .then(response => response.text()) .then(() => done()) .catch(err => done(err)); }) .on(END_EVENT, () => console.log('All done!')); ['https://example.com', 'https://example.org', 'https://example.net'] .forEach(url => queue.enqueue(new URL(url)));
Debug
Known issues
gotchaThe enqueue method expects a URL object, not a string. Passing a string will throw.
fix
Use `new URL('http://example.com')` when calling `queue.enqueue()`.
affects: >=5.0.0
gotchaThe ignoreSubdomains option is not available in browser builds due to file size.
fix
Do not use ignoreSubdomains in browser environments; set to false.
affects: >=5.0.0
breakingVersion 5 changed from CommonJS to ESM-only source. The require() syntax now requires destructuring from the default export.
fix
Use `const { default: RequestQueue } = require('limited-request-queue')` or switch to ESM import.
affects: >=5.0.0
deprecatedThe 'ignorePorts' option is deprecated in favor of using the 'ignoreSubdomains' pattern.
fix
Use `ignoreSubdomains: false` and adjust host grouping logic.
affects: >=5.0.0
Errors
Common errors & fixes
TypeError: queue.enqueue is not a function
Importing the module incorrectly (e.g., trying to use require on ESM).
fix
Use import or correct CommonJS destructuring: import RequestQueue from 'limited-request-queue'
TypeError: url must be a URL instance
Passing a string to enqueue instead of a URL object.
fix
Use `new URL(string)` when calling enqueue.
Cannot destructure property 'default' of ... as it is undefined.
Mixing ESM and CJS incorrectly (e.g., importing default export with destructuring).
fix
Ensure consistent module system usage. For CJS: const { default: RequestQueue } = require(...)
Upgrade
Version history
5.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
limited-request-queue — npm install limited-request-queue · libregistry