Registry / devops / stubborn-queue

stubborn-queue

JSON →
library2.0.0jsnpmunverified

A queue library for Node.js that continues processing tasks even if some fail, collecting errors for later handling rather than aborting the entire queue. Version 2.0.0 is the current stable release. Unlike typical async queues that halt on first error, this module ensures all tasks are attempted. It is inspired by d3-queue and supports concurrency control. Release cadence is low; the package is stable and simple.

npm install stubborn-queue
INSTALL
IMPORT
SIG · STUBBORN-QUEUE
S
stubborn-queue
devopsjavascriptv2.0.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
import q from 'stubborn-queue'
const queue = require('stubborn-queue').default
ESM only; no named exports.
default (CJS)
const queue = require('stubborn-queue')
const { queue } = require('stubborn-queue')
CJS import uses module.exports directly.

Creates a stubborn queue with concurrency 3, adds three readFile tasks, collects errors, and logs results on completion.

import q from 'stubborn-queue'; import { readFile } from 'fs/promises'; const results = []; const errors = []; q({ concurrency: 3 }) .add(readFile, '/path/to/file1.txt', 'utf8') .add(readFile, '/path/to/file2.txt', 'utf8') .add(readFile, '/path/to/file3.txt', 'utf8') .on('taskEnd', (err, result) => { if (err) errors.push(err); else results.push(result); }) .done((errs, res) => { console.log('Errors:', errs); console.log('Results:', res); });
Debug
Known issues
gotchaThe queue does not automatically serialize results order; results are collected in task completion order, not addition order.
fix
Use an external ordering mechanism (e.g., track indices).
affects: >=0.0.0
deprecatedEvent-based API (on) may not be available in all versions; check documentation.
fix
Upgrade to 2.x for consistent event support.
affects: <=1.x
gotchaWorks only in Node.js; no browser support (fs module dependency).
fix
Use in Node.js only.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: queue is not a function
Importing named export instead of default.
fix
Use import q from 'stubborn-queue' or const queue = require('stubborn-queue').
TypeError: q.add is not a function
Trying to call add on the factory function directly instead of on an instance.
fix
Create an instance: const q = queue(); then q.add(...).
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
4
Amazon
1
Resources
stubborn-queue — npm install stubborn-queue · libregistry