Registry / devops / promise-task-queue

promise-task-queue

JSON →
library1.2.0jsnpmunverified

A configurable task queue with first-class Promise support, concurrency control, and rate-limiting using intervals between tasks (not bursty X per Y). v1.2.0 (2016) is the latest stable; low maintenance cadence. Supports any Promises/A+ compatible library (Bluebird, ES6, Q). Lightweight and focused on task queues with events for metrics.

npm install promise-task-queue
INSTALL
IMPORT
SIG · PROMISE-TASK-QUEUE
P
promise-task-queue
devopsjavascriptv1.2.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.

default
var taskQueue = require('promise-task-queue');
import taskQueue from 'promise-task-queue';
This package does not export an ES module; use CommonJS require(). There is no default export in ESM style.
Promise
var Promise = require('bluebird');
var Promise = global.Promise;
Library uses Promises/A+; it's recommended to use a polyfill like bluebird for compatibility, though any Promises/A+ implementation works.
queue.on
var queue = taskQueue(); queue.on('failed:apiRequest', function(task) { ... });
queue.addEventListener('failed', handler);
Use .on() for events (EventEmitter style), not addEventListener.

Defines a task type 'apiRequest' with concurrency 2, pushes a task, and handles events on failure.

var Promise = require('bluebird'); var bhttp = require('bhttp'); var taskQueue = require('promise-task-queue'); var queue = taskQueue(); var failedRequests = 0; queue.on('failed:apiRequest', function(task) { failedRequests += 1; }); queue.define('apiRequest', function(task) { return Promise.try(function() { return bhttp.get('http://api.example.com/users/' + task.username, {decodeJSON: true}); }).then(function(response) { return response.body; }); }, { concurrency: 2 }); return queue.push('apiRequest', {username: 'joepie91'}).then(function(jsonResponse) { console.log('This user has ' + jsonResponse.repositoryCount + ' repositories.'); });
Debug
Known issues
gotchaNo ES module export; requires CommonJS require().
fix
Use const taskQueue = require('promise-task-queue'); instead of import.
affects: >=1.0.0
gotchaRate-limiting uses intervals between tasks, not 'X requests per Y seconds'.
fix
If you need burst-style rate limiting, use a different library like bottleneck.
affects: >=0.0.0
deprecatedThe package is in maintenance mode; no new features expected since 2016.
fix
Consider migrating to modern alternatives like p-queue or bottleneck for active support.
affects: >=1.2.0
gotchaEvent names are prefixed with task type (e.g., 'failed:apiRequest'), not generic names.
fix
Listen for events like 'failed:taskType', not just 'failed'.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: taskQueue is not a function
Importing the module incorrectly (e.g., using ES import syntax without a default export).
fix
Use const taskQueue = require('promise-task-queue');
Error: No handler defined for task type 'myTask'
Pushing a task for a type that hasn't been defined with queue.define().
fix
Call queue.define('myTask', handler, options) before queue.push('myTask', data).
DeprecationWarning: Using Promises without a polyfill may cause issues.
The library expects a Promises/A+ polyfill; older Node versions don't have native Promise.
fix
Add 'var Promise = require('bluebird');' before using the queue.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
bluebirdoptionalExample usage uses Bluebird; library works with any Promises/A+ but recommends Bluebird for features.
Agent activity
6 hits · last 30 days
node
6
Resources
promise-task-queue — npm install promise-task-queue · libregistry