Registry / storage / node-persistent-queue

node-persistent-queue

JSON →
library1.0.5jsnpmunverified

A simple SQLite-backed FIFO queue for running many short tasks sequentially in Node.js event thread without blocking. Version 1.0.5, last released in 2018. Uses setImmediate() to allow event loop to poll between tasks. Differentiates from in-memory queues or worker threads by providing persistence via SQLite and promise-based API. Ideal for small tasks that must survive crashes/restarts.

npm install node-persistent-queue
INSTALL
IMPORT
SIG · NODE-PERSISTENT-QU
N
node-persistent-queue
storagejavascriptv1.0.5
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
const Queue = require('node-persistent-queue')
import Queue from 'node-persistent-queue'
CJS-only; no ESM or default export. Use require.
Queue instance
new Queue('./path/to/db.sqlite')
new Queue()
First argument is required (database path or ':memory:').
events
q.on('start', callback)
q.on('start', callback())
Events: start, stop, error, drain. Do not invoke callback in on().

Creates a persistent queue, adds a task, and starts processing with event handlers.

const Queue = require('node-persistent-queue'); const q = new Queue('./myqueue.sqlite'); q.on('drain', () => console.log('All tasks done')); q.on('error', err => console.error(err)); q.push({task: 'send-email', to: 'user@example.com'}); q.on('task_finish', (task) => console.log('Finished', task)); q.start();
Debug
Known issues
breakingRequires Node.js >=6.0.0; may not work on newer versions with enhanced security.
fix
Update Node.js to LTS version or use a more modern queue library.
affects: >=1.0.0
gotchaQueue must be started with .start() after adding listeners, or tasks will not be processed.
fix
Call q.start() after setting up event handlers.
affects: >=1.0.0
gotchaDatabase file path must be writeable; if path does not exist, it will be created. Using ':memory:' disables persistence.
fix
Ensure directory exists and is writable.
affects: >=1.0.0
deprecatedPackage not updated since 2018; consider migrating to more modern alternatives like Bull or Agenda.
fix
Evaluate alternatives for active maintenance.
affects: >=1.0.0
Errors
Common errors & fixes
Error: SQLITE_ERROR: no such table: jobs
Database table 'jobs' not created automatically if instantiated incorrectly or database is empty.
fix
Ensure first argument is a valid path; the table is created on first .push() call.
TypeError: q.push is not a function
Queue instance not properly created, e.g., missing 'new'.
fix
Use 'new Queue(path)' instead of just 'Queue(path)'.
events.js:167 throw er; // Unhandled 'error' event
No error listener attached; queue errors are emitted as 'error' events.
fix
Add q.on('error', console.error) before calling q.start().
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
better-sqlite3requiredSQLite driver for persistent storage
debugoptionalDebugging utility
Agent activity
17 hits · last 30 days
node
14
Resources
node-persistent-queue — npm install node-persistent-queue · libregistry