Registry / database / bang-queue

bang-queue

JSON →
library1.3.29jsnpmunverified

Bang-queue is a simple FIFO job queue for Node.js backed by MongoDB. It provides basic features like job creation with delay and timeout, event-driven job processing, and explicit job completion/deletion. The current stable version is 1.3.29, released with low cadence. It distinguishes itself by minimal setup and reliance solely on MongoDB, with no external dependencies beyond the MongoDB driver. Suitable for small-scale workloads where a full-featured queue like Bull or Kue is overkill.

npm install bang-queue
INSTALL
IMPORT
SIG · BANG-QUEUE
B
bang-queue
databasejavascriptv1.3.29
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.

Bang
import { Bang } from 'bang-queue'
const Bang = require('bang-queue').Bang
The package exports a named Bang class, not default. Use named import or destructured require.
Bang (constructor)
const queue = new Bang('mongodb://...', 'myqueue', { REFRESH_DELAY: 1000 })
new Bang('mongodb://...', 'myqueue')
The constructor expects the URI as first argument, queue name second, and optional params object third.
createJob
queue.createJob('email', { to: 'user@example.com' }, { timeout: 10000 })
queue.createJob({ type: 'email', data: {...} })
createJob takes three arguments: jobType (string), arguments (object), and optional params object.

Creates a queue, enqueues a job, listens for the job type, processes it, and deletes it from the queue.

import { Bang } from 'bang-queue'; async function main() { const queue = new Bang(process.env.MONGO_URI ?? 'mongodb://localhost:27017/test', 'myqueue'); await queue.createJob('sendEmail', { to: 'user@example.com', subject: 'Hello' }); queue.on('sendEmail', 5, (err, job) => { if (err) console.error(err); else if (job) { console.log('Processing job', job._id, job.arguments); queue.setCompleteJob(job._id, { delete: true }).catch(console.error); } }); } main().catch(console.error);
Debug
Known issues
gotchaJobs not completed via setCompleteJob will be reprocessed indefinitely.
fix
Always call setCompleteJob(jobId, { delete: true }) after successful processing.
affects: >=0.0.0
gotchaThe 'params' argument in createJob sets timeout and delay, but delay is not documented clearly and may behave unexpectedly.
fix
Test delay behavior in your environment or avoid using delay.
affects: >=0.0.0
deprecatedNo recent releases; package may be unmaintained.
fix
Consider migrating to a more active queue library like Bull or Bee-Queue.
affects: <1.4.0
gotchaQueue name must be consistent; using different names creates separate queues.
fix
Use a single queue name per logical queue instance.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Bang is not a constructor
Using default import instead of named import.
fix
Use `import { Bang } from 'bang-queue'` or `const { Bang } = require('bang-queue')`
MongoError: Authentication failed
MongoDB URI missing credentials or incorrect database.
fix
Ensure URI includes auth source: `mongodb://user:pass@host:port/db?authSource=admin`
Job not processed; listener doesn't fire
Queue listener registered after job creation, or concurrency limit reached.
fix
Register listeners before creating jobs; increase concurrency parameter in `.on('type', concurrency, ...)`
Job stuck in queue after processing
Missing setCompleteJob call.
fix
Call `queue.setCompleteJob(job._id, { delete: true })` after successful processing.
Upgrade
Version history
1.3.29latest on npm
Audit
Dependencies
mongodbrequiredBang-queue uses MongoDB as its backend store for jobs.
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
bang-queue — npm install bang-queue · libregistry