Registry / devops / nxus-worker-queue

nxus-worker-queue

JSON →
library4.0.6jsnpmunverified

Worker queue module for Nxus applications using Redis and Bull for pub/sub background tasks. Version 4.0.6 is current. Uses Bull for robust, Redis-backed job queues with features like delayed jobs, retries, and job completion notifications via promises. Differentiator: integrates tightly with Nxus framework but can be used standalone. Release cadence is irregular; last release was 2020.

npm install nxus-worker-queue
INSTALL
IMPORT
SIG · NXUS-WORKER-QUEUE
N
nxus-worker-queue
devopsjavascriptv4.0.6
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.

workerQueue
import { workerQueue } from 'nxus-worker-queue'
import workerQueue from 'nxus-worker-queue'
Must use named import; default import is not exported.
WorkerQueue
import { WorkerQueue } from 'nxus-worker-queue'
import WorkerQueue from 'nxus-worker-queue'
Constructor is a named export; ESM-only.
workerQueue
const { workerQueue } = require('nxus-worker-queue')
const workerQueue = require('nxus-worker-queue')
CommonJS require destructuring needed; library is ESM-first but provides CJS compatibility.

Shows registering a worker handler for 'sendEmail' tasks, queueing a task with data, and awaiting job completion via job.finished().

import { workerQueue } from 'nxus-worker-queue' // Register a worker handler workerQueue.worker('sendEmail', async (job) => { console.log('Processing job:', job.id, 'with data:', job.data) // Simulate work await new Promise(resolve => setTimeout(resolve, 1000)) return { status: 'sent' } }) // Queue a task async function queueEmail(recipient) { const job = await workerQueue.task('sendEmail', { to: recipient, subject: 'Hello' }) console.log('Job queued:', job.id) // Wait for completion (optional) const result = await job.finished() console.log('Job result:', result) } queueEmail('user@example.com').catch(console.error)
Debug
Known issues
breakingVersion 4.x requires Bull v3+. Older Bull 2.x API is incompatible.
fix
If upgrading from 3.x, ensure Bull is upgraded to v3. Job opts may differ.
affects: >=4.0
gotchaworker() expects handler to return a promise; non-promise returns may cause unexpected behavior.
fix
Always return a promise from worker handler, even if async.
affects: *
gotchatask() returns a Bull Job, not a promise. Must call .finished() to get completion promise.
fix
Use job.finished() after workerQueue.task() to await result.
affects: *
deprecatedThe 'opts' parameter in worker() is deprecated; use Bull Queue options instead.
fix
Pass options to Bull queue directly, not via worker() third arg.
affects: >=4.0
gotchaRedis URL must be set via config or process.env.REDIS_URL; default is localhost:6379.
fix
Set worker_queue.redis_url in config or export REDIS_URL environment variable.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'bull'
Missing peer dependency bull
fix
npm install bull --save
TypeError: workerQueue.worker is not a function
Using default import instead of named import
fix
Use import { workerQueue } from 'nxus-worker-queue'
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server not running or wrong host/port
fix
Start redis-server or set REDIS_URL env variable
TypeError: job.finished is not a function
Calling .finished() on queue, not on job returned by task()
fix
const job = await workerQueue.task('name', data); await job.finished();
Upgrade
Version history
4.0.6latest on npm
Audit
Dependencies
bullrequiredRedis-backed job queue library
redisrequiredRedis client required by Bull
Agent activity
4 hits · last 30 days
node
4
Resources
nxus-worker-queue — npm install nxus-worker-queue · libregistry