Registry / workflow / node-resque

node-resque

JSON →
library9.5.0jsnpmunverified

node-resque is an opinionated, Redis-backed (version 2.6.0 and up required) background job processing system for Node.js, currently stable at version 9.5.0. It provides features like priority queues, plugins, locking, and delayed jobs, implementing an API largely compatible with Ruby's Resque and Sidekiq. The project actively maintains and releases new versions, primarily consisting of dependency bumps and minor fixes in recent changelogs. Since version 6, the codebase transitioned to TypeScript, though transpiled JavaScript is still provided. Version 5 introduced `async/await`, making Node.js 8.0.0+ a minimum requirement and breaking compatibility with older versions due to changes in API paradigms.

npm install node-resque
INSTALL
IMPORT
SIG · NODE-RESQUE
N
node-resque
workflowjavascriptv9.5.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Worker
import { Worker } from 'node-resque';
const Worker = require('node-resque').Worker;
ESM import is preferred since v6 due to TypeScript source. CommonJS `require` still works for transpiled output but type definitions are for ESM.
Scheduler
import { Scheduler } from 'node-resque';
const Scheduler = require('node-resque').Scheduler;
The Scheduler manages delayed jobs and performs cluster cleanup.
Queue
import { Queue } from 'node-resque';
const Queue = require('node-resque').Queue;
The Queue is the primary interface for enqueuing and managing jobs.
Job
import type { Job } from 'node-resque';
Recommended for TypeScript users to define job interfaces.

This quickstart demonstrates how to set up a node-resque worker, scheduler, and queue, connect them to Redis, define and enqueue jobs (including delayed jobs), and handle job outcomes.

import { Worker, Scheduler, Queue } from "node-resque"; const connectionDetails = { pkg: "ioredis", host: "127.0.0.1", password: null, port: 6379, database: 0, }; const jobs = { 'testJob': { perform: async (a: number, b: number) => { const result = a + b; console.log(`Job 'testJob' performed with ${a} + ${b} = ${result}`); return result; }, }, 'delayedJob': { perform: async (message: string) => { console.log(`Delayed job received: ${message}`); return `Processed: ${message}`; } } }; async function boot() { const queue = new Queue({ connection: connectionDetails, jobs }); await queue.connect(); const worker = new Worker({ connection: connectionDetails, queues: ['default'], jobs }); worker.on('start', () => console.log('Worker started')); worker.on('end', () => console.log('Worker ended')); worker.on('success', (queue, job, result) => console.log(`Job success in ${queue}: ${JSON.stringify(job)} => ${result}`)); worker.on('failure', (queue, job, error) => console.error(`Job failure in ${queue}: ${JSON.stringify(job)} => ${error}`)); worker.on('error', (error, queue, job) => console.error(`Worker error: ${error} in ${queue} for ${JSON.stringify(job)}`)); const scheduler = new Scheduler({ connection: connectionDetails, jobs }); scheduler.on('start', () => console.log('Scheduler started')); scheduler.on('end', () => console.log('Scheduler ended')); scheduler.on('error', (error, queue, job) => console.error(`Scheduler error: ${error} in ${queue} for ${JSON.stringify(job)}`)); await worker.connect(); await worker.start(); await scheduler.connect(); await scheduler.start(); // Enqueue a simple job await queue.enqueue('default', 'testJob', [1, 2]); // Enqueue a delayed job to run in 5 seconds await queue.enqueueIn(5 * 1000, 'default', 'delayedJob', ['This is a delayed message!']); console.log('Jobs enqueued. Waiting for workers...'); // Keep the process alive for a bit to allow jobs to process setTimeout(async () => { await worker.end(); await scheduler.end(); await queue.end(); console.log('Node-resque example finished.'); process.exit(); }, 10000); } boot().catch(console.error);
Debug
Known issues
breakingNode-resque v5+ transitioned to `async/await`. This is a breaking change with no direct upgrade path from versions prior to v5, requiring adaptation of job definitions and worker logic. Node.js v8.0.0 or higher is required.
fix
Rewrite job `perform` functions and any interaction logic to use `async/await` syntax. Ensure your Node.js version is `8.0.0` or newer.
affects: >=5.0.0
breakingNode-resque v6+ rewrote its source in TypeScript. While transpiled JavaScript is provided, developers using TypeScript should ensure their build processes are compatible. While functionality between v5 and v6 should be the same, the internal structure and type definitions changed.
fix
For TypeScript projects, ensure correct `tsconfig.json` setup and `import` statements. Review API documentation for updated types and interfaces.
affects: >=6.0.0
gotchaRedis version 2.6.0 or higher is required due to node-resque's reliance on Lua scripting for atomic operations.
fix
Ensure your Redis server is at version 2.6.0 or newer. Consult Redis documentation for upgrade instructions if necessary.
affects: >=1.0.0
gotchaAs of v9.3.7, `enqueueIn` and `enqueueAt` methods now explicitly return booleans, indicating the success of the enqueue operation. Previously, their return behavior might have been less explicit or callback-oriented.
fix
Update any code that relies on the return value or side effects of `enqueueIn` or `enqueueAt` to expect and handle a boolean result.
affects: >=9.3.7
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use CommonJS `require()` syntax in an ESM-context (e.g., `"type": "module"` in `package.json`) for a module that primarily supports ESM or provides ESM type definitions, particularly after v6's TypeScript transition.
fix
Use ESM `import` statements: `import { Worker } from 'node-resque';`. If you must use `require()`, consider setting `"type": "commonjs"` in your `package.json` or explicitly compiling to CommonJS if using TypeScript.
Error: connect ECONNREFUSED 127.0.0.1:6379
The Redis server is not running or is not accessible at the specified host and port.
fix
Ensure your Redis server is running and configured to accept connections on the host and port specified in your `connectionDetails`. Check firewall rules or Redis configuration (`redis.conf`).
UnhandledPromiseRejectionWarning: Unhandled promise rejection
An `async` job's `perform` function or other asynchronous operation within node-resque threw an error or rejected a promise without being caught by a `try/catch` block or `.catch()` handler.
fix
Always wrap `async` operations in `try/catch` blocks within your job `perform` functions and add `.catch()` handlers to any promises. Implement `worker.on('error', ...)` and `queue.on('error', ...)` listeners to handle errors gracefully.
TypeError: job.perform is not a function
The `jobs` object passed to the Worker or Queue constructor does not correctly define a function for the job name being enqueued or processed.
fix
Ensure the `jobs` object contains a key matching the job name, and its value is an object with a `perform` property that is an `async` function, e.g., `{ 'myJobName': { perform: async (arg) => { /* ... */ } } }`.
Upgrade
Version history
9.5.0latest on npm
Audit
Dependencies
ioredisrequiredOfficial Redis client recommended and used for connections.
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
node-resque — npm install node-resque · libregistry