Registry / storage / plain-queue

plain-queue

JSON →
library4.0.0jsnpmunverified

A lightweight queue library for Node.js that manages asynchronous task execution with configurable per-task timeouts and garbage collection of completed tasks. Version 4.0.0 requires Node.js 4+ and ships TypeScript types. Unlike many job queues, plain-queue is in-process, single-threaded, and has no persistence or external dependencies, making it ideal for simple sequential task orchestration. The library supports both promise-returning and synchronous functions, and provides timeout errors when a task exceeds the specified limit. Release cadence is low; the API has been stable since v1.0.2.

npm install plain-queue
INSTALL
IMPORT
SIG · PLAIN-QUEUE
P
plain-queue
storagejavascriptv4.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.

Queue
import { Queue } from 'plain-queue'
const Queue = require('plain-queue')
Queue is a named export, not default. In CommonJS use destructuring: const { Queue } = require('plain-queue').
TimeoutError
import { TimeoutError } from 'plain-queue'
TimeoutError is also a named export. Available for checking task timeout errors.
types
import type { QueueOptions, TaskOptions } from 'plain-queue'
TypeScript types are available as named exports; no separate typings package needed.

Creates a queue with a 5-second global timeout and 300-task GC threshold, then adds an async task and logs its result.

const { Queue } = require('plain-queue'); const queue = new Queue({ taskTimeout: 5000, gcThreshold: 300 }); queue.addTask(async () => { const result = await someAsyncWork(); return result; }).then(console.log).catch(console.error); function someAsyncWork() { return Promise.resolve('Task done'); }
Debug
Known issues
breakingVersion 4.0.0 drops support for Node.js < 4.0.0. Upgrade Node or pin to older version.
fix
Ensure Node.js >= 4.0.0, or use plain-queue@3.x for older Node.
affects: >=4.0.0
gotchaThe Queue constructor's 'taskTimeout' option only applies per-task if no 'timeout' is specified in addTask. Per-task timeout overrides the global one.
fix
Set both global and per-task timeouts explicitly if needed.
affects: all
gotchaIf the task function does not return a promise, it is considered completed immediately. This may cause unexpected behavior if the function starts an async operation without returning a promise.
fix
Always return a promise for async tasks.
affects: all
deprecatedThere is no active deprecation in the library, but the API has been stable for years; check docs for any removal of older methods.
fix
No action required.
affects: >=4.0.0
Errors
Common errors & fixes
TypeError: require(...) is not a constructor
Trying to instantiate Queue as default import in CommonJS: const Queue = require('plain-queue'); new Queue();
fix
Use destructuring: const { Queue } = require('plain-queue');
Error: Task timeout [5000ms]
A task exceeded the configured timeout (default 5000ms).
fix
Increase timeout in queue options or per-task options, or reduce task execution time.
Module not found: Error: Can't resolve 'plain-queue'
Package not installed or import path misspelled.
fix
Run npm install plain-queue and check import: import { Queue } from 'plain-queue';
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Amazon
1
Resources
plain-queue — npm install plain-queue · libregistry