{"id":13658,"library":"node-resque","title":"node-resque","description":"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.","status":"active","version":"9.5.0","language":"javascript","source_language":"en","source_url":"git://github.com/actionhero/node-resque","tags":["javascript","delayed","queue","resque","redis","work","worker","background","job","typescript"],"install":[{"cmd":"npm install node-resque","lang":"bash","label":"npm"},{"cmd":"yarn add node-resque","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-resque","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Official Redis client recommended and used for connections.","package":"ioredis","optional":false}],"imports":[{"note":"ESM import is preferred since v6 due to TypeScript source. CommonJS `require` still works for transpiled output but type definitions are for ESM.","wrong":"const Worker = require('node-resque').Worker;","symbol":"Worker","correct":"import { Worker } from 'node-resque';"},{"note":"The Scheduler manages delayed jobs and performs cluster cleanup.","wrong":"const Scheduler = require('node-resque').Scheduler;","symbol":"Scheduler","correct":"import { Scheduler } from 'node-resque';"},{"note":"The Queue is the primary interface for enqueuing and managing jobs.","wrong":"const Queue = require('node-resque').Queue;","symbol":"Queue","correct":"import { Queue } from 'node-resque';"},{"note":"Recommended for TypeScript users to define job interfaces.","symbol":"Job","correct":"import type { Job } from 'node-resque';"}],"quickstart":{"code":"import { Worker, Scheduler, Queue } from \"node-resque\";\n\nconst connectionDetails = {\n  pkg: \"ioredis\",\n  host: \"127.0.0.1\",\n  password: null,\n  port: 6379,\n  database: 0,\n};\n\nconst jobs = {\n  'testJob': {\n    perform: async (a: number, b: number) => {\n      const result = a + b;\n      console.log(`Job 'testJob' performed with ${a} + ${b} = ${result}`);\n      return result;\n    },\n  },\n  'delayedJob': {\n    perform: async (message: string) => {\n      console.log(`Delayed job received: ${message}`);\n      return `Processed: ${message}`;\n    }\n  }\n};\n\nasync function boot() {\n  const queue = new Queue({ connection: connectionDetails, jobs });\n  await queue.connect();\n\n  const worker = new Worker({ connection: connectionDetails, queues: ['default'], jobs });\n  worker.on('start', () => console.log('Worker started'));\n  worker.on('end', () => console.log('Worker ended'));\n  worker.on('success', (queue, job, result) => console.log(`Job success in ${queue}: ${JSON.stringify(job)} => ${result}`));\n  worker.on('failure', (queue, job, error) => console.error(`Job failure in ${queue}: ${JSON.stringify(job)} => ${error}`));\n  worker.on('error', (error, queue, job) => console.error(`Worker error: ${error} in ${queue} for ${JSON.stringify(job)}`));\n\n  const scheduler = new Scheduler({ connection: connectionDetails, jobs });\n  scheduler.on('start', () => console.log('Scheduler started'));\n  scheduler.on('end', () => console.log('Scheduler ended'));\n  scheduler.on('error', (error, queue, job) => console.error(`Scheduler error: ${error} in ${queue} for ${JSON.stringify(job)}`));\n\n  await worker.connect();\n  await worker.start();\n  await scheduler.connect();\n  await scheduler.start();\n\n  // Enqueue a simple job\n  await queue.enqueue('default', 'testJob', [1, 2]);\n\n  // Enqueue a delayed job to run in 5 seconds\n  await queue.enqueueIn(5 * 1000, 'default', 'delayedJob', ['This is a delayed message!']);\n\n  console.log('Jobs enqueued. Waiting for workers...');\n\n  // Keep the process alive for a bit to allow jobs to process\n  setTimeout(async () => {\n    await worker.end();\n    await scheduler.end();\n    await queue.end();\n    console.log('Node-resque example finished.');\n    process.exit();\n  }, 10000);\n}\n\nboot().catch(console.error);\n","lang":"typescript","description":"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."},"warnings":[{"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.","message":"Node-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.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"For TypeScript projects, ensure correct `tsconfig.json` setup and `import` statements. Review API documentation for updated types and interfaces.","message":"Node-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.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Ensure your Redis server is at version 2.6.0 or newer. Consult Redis documentation for upgrade instructions if necessary.","message":"Redis version 2.6.0 or higher is required due to node-resque's reliance on Lua scripting for atomic operations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update any code that relies on the return value or side effects of `enqueueIn` or `enqueueAt` to expect and handle a boolean result.","message":"As 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.","severity":"gotcha","affected_versions":">=9.3.7"}],"env_vars":null,"search_vec":"'2.6.0':14 '5':85 '6':72 '8.0.0':90 '9.5.0':28 'activ':53 'api':42,104 'async/await':87 'back':12 'background':18,113 'break':95 'bump':63 'chang':102 'changelog':69 'codebas':74 'compat':44,96 'consist':60 'current':24 'delay':38,107 'depend':62 'due':100 'featur':31 'fix':66 'implement':40 'introduc':86 'javascript':80,106 'job':19,39,114 'larg':43 'like':32 'lock':36 'maintain':54 'make':88 'minimum':92 'minor':65 'new':57 'node':2,5 'node-resqu':1,4 'node.js':23,89 'older':98 'opinion':9 'paradigm':105 'plugin':35 'primarili':59 'prioriti':33 'process':20 'project':52 'provid':30,83 'queue':34,108 'recent':68 'redi':11,110 'redis-back':10 'releas':56 'requir':17,93 'resqu':3,6,48,109 'rubi':46 'sidekiq':50 'sinc':70 'stabl':25 'still':82 'system':21 'though':78 'transit':75 'transpil':79 'typescript':77,115 'version':13,27,58,71,84,99 'work':111 'worker':112","created_at":"2026-04-20T01:55:38.273847+00:00","updated_at":"2026-04-20T01:55:38.273847+00:00","problems":[{"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.","cause":"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.","error":"TypeError: require is not a function"},{"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`).","cause":"The Redis server is not running or is not accessible at the specified host and port.","error":"Error: connect ECONNREFUSED 127.0.0.1:6379"},{"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.","cause":"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.","error":"UnhandledPromiseRejectionWarning: Unhandled promise rejection"},{"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) => { /* ... */ } } }`.","cause":"The `jobs` object passed to the Worker or Queue constructor does not correctly define a function for the job name being enqueued or processed.","error":"TypeError: job.perform is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/actionhero/node-resque","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/node-resque","openapi_spec":null,"status_page":null,"smithery":null,"categories":["workflow","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}