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 'queue-system'
✗ const Queue = require('queue-system').Queue
ESM only; default export is not available.
Task
✓ import type { Task } from 'queue-system'
TypeScript type for tasks; not a runtime value.
QueueEvents
✓ import { QueueEvents } from 'queue-system'
✗ import { Events } from 'queue-system'
QueueEvents is the correct event enum name.
Creates a queue with concurrency 2, adds two tasks, starts, pauses, inserts a priority task, and resumes.
import { Queue } from 'queue-system';
const queue = new Queue({ concurrency: 2 });
queue.on('taskComplete', (result) => {
console.log('Task completed:', result);
});
queue.add(() => new Promise(resolve => setTimeout(() => resolve('First'), 1000)));
queue.add(() => new Promise(resolve => setTimeout(() => resolve('Second'), 500)));
queue.start();
setTimeout(() => {
queue.pause();
console.log('Paused');
// Insert a high-priority task at the front
queue.add(() => Promise.resolve('Urgent'), { priority: true });
queue.start();
}, 200);
Debug
Known issues
breakingVersion 3.0.0 changed the API: queue is no longer a function constructor; use new Queue() instead.fixUse class instantiation: const queue = new Queue(options);
affects: <3.0.0 || >=3.0.0
breakingEvents API renamed from 'task-complete' to 'taskComplete' in v4.0.0.fixUse camelCase event names: queue.on('taskComplete', handler). affects: >=4.0.0
breakingCancellation behaviour changed in v4.0.0: running tasks are now cancelled by default when destroy() is called.fixUse destroy({ cancelRunning: false }) to preserve old behaviour. affects: >=4.0.0
deprecatedThe option 'forceStart' is deprecated; use 'add' with { force: true } instead.fixqueue.add(task, { force: true }); affects: >=3.5.0
gotchaConcurrency set to 0 will block all tasks; no tasks will run until concurrency is increased.fixSet concurrency to at least 1 if you expect tasks to execute immediately.
affects: *
Errors
Common errors & fixes
Queue is not a constructor
Importing incorrectly in CommonJS or using version <3.0.0 with wrong syntax.
fixUse import { Queue } from 'queue-system' (ESM) or const { Queue } = require('queue-system') (CommonJS). Cannot find module 'queue-system'
Package not installed or module resolution misconfigured (e.g., missing .js extension in ESM).
fixRun npm install queue-system. For ESM, ensure import uses correct path and Node v12+.
task.cancel is not a function
Attempting to cancel a task that has already completed or was not returned from queue.add().
fixCapture the task object: const task = queue.add(...); then call task.cancel() before it finishes.
Audit
Dependencies
event-emitter-ishrequiredUsed for event handling; bundled dependency but may appear in node_modules.