Registry / database / atomic-queue

atomic-queue

JSON →
library5.0.4jsnpmunverified

A crash-friendly queue for Node.js that persists queue state to disk and can safely restart after a crash. Uses a worker pool with configurable concurrency. Version 5.0.4 is the latest stable release; maintenance is infrequent. Key differentiators: zero external dependencies beyond core Node modules (LevelDB fork removed after v4), simple stream-based API, and automatic persistence of queue state. Compared to alternatives like Bull or Kue, it is minimal, with no Redis dependency. Primarily used in server-side applications requiring durable job processing without a dedicated message broker.

npm install atomic-queue
INSTALL
IMPORT
SIG · ATOMIC-QUEUE
A
atomic-queue
databasejavascriptv5.0.4
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 queue from 'atomic-queue'
const { queue } = require('atomic-queue')
The package exports a single function via default export. Use default import for ESM.
default
const queue = require('atomic-queue')
const { atomicQueue } = require('atomic-queue')
CommonJS users must call require() directly; there is no named export.
Queue
import queue from 'atomic-queue'
import { Queue } from 'atomic-queue'
There is no named export 'Queue'. Use default import to get the constructor function.

Shows how to create a queue with a worker function, write jobs, handle events, and end the queue.

import queue from 'atomic-queue'; import { createWriteStream } from 'fs'; const work = (data, done) => { console.log('Processing:', data); done(null); }; const q = queue(work, { concurrency: 5 }); q.on('ready', () => { console.log('Queue ready'); q.write('job1'); q.write('job2'); q.end(); }); q.on('error', (err) => { console.error('Queue error:', err); }); q.on('finish', () => { console.log('All jobs done'); });
Debug
Known issues
breakingDropped built-in LevelDB persistence in v5. State persistence uses a simple JSON file by default, not LevelDB.
fix
No action needed unless you relied on LevelDB-specific features. Persisted state is now a JSON file at process.cwd()/queue-state.json.
affects: >=5.0.0
breakingAPI changed from constructor to factory function. You must call queue() directly, not with 'new'.
fix
Replace 'new queue(worker, opts)' with 'queue(worker, opts)'.
affects: >=5.0.0
gotchaWorker function must call done() exactly once per job. Not calling done() causes the queue to hang.
fix
Ensure your worker invokes done(null) on success or done(err) on failure.
affects: >=0.0.0
deprecatedThe 'pool' events (start/finish) are deprecated and may be removed in a future major version.
fix
Use queue-level events like 'idle' and 'finish' instead.
affects: >=5.0.0
Errors
Common errors & fixes
TypeError: queue is not a constructor
Using 'new queue()' syntax but the package exports a factory function in v5+.
fix
Remove 'new' and call queue(worker, opts) directly.
Error: Cannot find module 'level'
v4 and earlier required LevelDB; v5 dropped it. Old code tries to require 'level'.
fix
Update to v5 and remove any explicit LevelDB dependency.
ReferenceError: queue is not defined
Trying to import a named export 'queue' instead of default import.
fix
Use default import: import queue from 'atomic-queue' or const queue = require('atomic-queue')
Upgrade
Version history
5.0.4latest on npm
Audit
Dependencies
readable-streamrequiredUsed internally for stream implementation
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
atomic-queue — npm install atomic-queue · libregistry