Registry / testing / limiting-queue

limiting-queue

JSON →
library1.2.1jsnpmunverified

A Node.js promise-based queue that processes items via a user-defined callback with configurable concurrency, retries, timeouts, and queue size limits. Version 1.2.1 is stable, with low release cadence (last update 2015). Compared to alternatives like async.queue or bull, it offers a simpler, promise-free API (uses deferreds) and built-in retry/timeout per item. No external dependencies. Supports ESM/CJS via require(). Ships with TypeScript types via DefinitelyTyped (@types/limiting-queue).

npm install limiting-queue
INSTALL
IMPORT
SIG · LIMITING-QUEUE
L
limiting-queue
testingjavascriptv1.2.1
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.

LimitingQueue
import LimitingQueue from 'limiting-queue'
const LimitingQueue = require('limiting-queue').default
ESM default import works; CommonJS require gives the constructor directly.
LimitingQueue
const LimitingQueue = require('limiting-queue')
const { LimitingQueue } = require('limiting-queue')
CJS: the module exports a single function/constructor, not a named export.
LimitingQueueOptions
import type { LimitingQueueOptions } from 'limiting-queue'
import { LimitingQueueOptions } from 'limiting-queue'
Only available as a type export if using @types/limiting-queue; otherwise you must define your own interface.

Creates a limiting-queue with concurrency 2, retries 3, timeout 5s, and a callback that fulfills/rejects via deferred. Shows push and start.

import LimitingQueue from 'limiting-queue'; const queue = new LimitingQueue({ maxWorkers: 2, maxRetries: 3, maxWait: 5000, callback: (payload, previousAttempts, deferred) => { console.log('Processing:', payload); // Simulate async work setTimeout(() => { if (Math.random() > 0.2) { deferred.fulfill(); } else { deferred.reject(new Error('Random failure')); } }, 1000); }, failure: (payload, totalAttempts, errors) => { console.error('Failed after', totalAttempts, 'attempts:', errors); } }); queue.push({ id: 1 }); queue.push({ id: 2 }); queue.start();
Debug
Known issues
deprecatedThe deferred pattern (fulfill/reject) is outdated; prefer Promise-based queues.
fix
Use async.queue or p-limit for modern Promise support.
affects: all
gotchaqueue.push returns false if maxQueueSize exceeded, but does NOT throw or provide error details.
fix
Check return value: if (!queue.push(payload)) { /* handle queue full */ }
affects: >=1.0.0 <2.0.0
gotchaMixing prioritize() with push/append can cause unexpected ordering (absolute vs relative insertion).
fix
Stick to one insertion method consistently, or use only prioritize.
affects: all
gotchaOptions modified after initialization via queue.opts may not be used until next start/stop cycle.
fix
Call queue.stop() and queue.start() after changing options to ensure they take effect.
affects: all
gotchamaxWorkers set to -1 (no limit) may cause unbounded concurrency and crash on large queues.
fix
Always set a positive integer for maxWorkers, e.g., 5.
affects: all
Errors
Common errors & fixes
TypeError: LimitingQueue is not a constructor
Using import { LimitingQueue } instead of import LimitingQueue (CommonJS: require wrong).
fix
Use import LimitingQueue from 'limiting-queue' or const LimitingQueue = require('limiting-queue')
TypeError: Cannot read properties of undefined (reading 'fulfill')
Callback not receiving deferred object correctly; missing third parameter or using arrow function that loses context.
fix
Define callback with three parameters: function(payload, previousAttempts, deferred) { ... }
Error: queue.push is not a function
Forgetting to call new when instantiating queue.
fix
const queue = new LimitingQueue(options);
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
limiting-queue — npm install limiting-queue · libregistry