Registry / devops / promise-queue

promise-queue

JSON →
library2.2.5jsnpmunverified

A lightweight, promise-based concurrency queue for Node.js and browsers. Current stable version is 2.2.5 (last published in 2016). It limits the number of concurrently executing async functions and the maximum queue size. Key differentiators: simple API (add, getQueueLength, getPendingLength), configurable Promise implementation (supports custom promise libraries like Vow or jQuery), and no dependencies. Alternative to async.queue or p-limit with a minimal footprint.

npm install promise-queue
INSTALL
IMPORT
SIG · PROMISE-QUEUE
P
promise-queue
devopsjavascriptv2.2.5
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.

Queue
import Queue from 'promise-queue'
import { Queue } from 'promise-queue'
Default export only. Named import will not work.
Queue.Queue
import Queue from 'promise-queue'; const { Queue } = Queue;
import { Queue } from 'promise-queue'
Alternatively, you can access the constructor as a named export from the default export.
Queue (require)
const Queue = require('promise-queue');
const { Queue } = require('promise-queue');
CommonJS works, but destructuring from require will fail because default is the constructor itself.

Shows how to create a queue with concurrency limit and add async functions that return promises.

import Queue from 'promise-queue'; // Create a queue with max 2 concurrent promises const queue = new Queue(2, Infinity); async function fetchData(url: string) { return await queue.add(async () => { const response = await fetch(url); return response.json(); }); } // Usage fetchData('https://api.example.com/data').then(data => console.log(data));
Debug
Known issues
deprecatedNo updates since 2016; may have unhandled promise rejections in modern Node.js if not caught.
fix
Consider using p-limit or p-queue for active maintenance and better error handling.
affects: <=2.2.5
gotchaQueue default uses global Promise; if not available, Queue.configure must be called before use.
fix
Call Queue.configure(require('vow').Promise) or provide your own promise constructor.
affects: >=0.0.0
gotchaThe add method expects a function that returns a promise, not a promise itself. Passing a promise will cause issues.
fix
Always wrap the promise-returning operation in a function: queue.add(() => someAsyncCall()).
affects: >=0.0.0
gotchaIf maxQueued is reached, add will throw synchronously; no backpressure handling.
fix
Check queue.getQueueLength() before adding, or set maxQueued to Infinity to avoid synchronous throws.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: queue.add is not a function
Importing the module incorrectly (e.g., using named import instead of default).
fix
Use `import Queue from 'promise-queue'` or `const Queue = require('promise-queue')`.
UnhandledPromiseRejectionWarning: ...
A promise added to the queue rejected but no .catch handler attached to queue.add.
fix
Always chain .catch on the promise returned by queue.add, or use async/await with try/catch.
Queue is not a constructor
Using default import with named import syntax in ES6.
fix
Change to `import Queue from 'promise-queue'` (no curly braces).
Upgrade
Version history
2.2.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

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