{"id":46286,"library":"run-queue","title":"Run-Queue","description":"A promise-based, dynamic priority queue runner with concurrency limiting for Node.js. Version 2.0.1 is stable but receives only sporadic maintenance. It allows adding jobs with integer priorities, ensures that all jobs of a lower priority complete before higher priorities execute, and dynamically switches back to lower priorities if new jobs are added. Supports configurable concurrency (default 1) and custom Promise implementations. Lightweight with no runtime dependencies.","status":"maintenance","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/iarna/run-queue","tags":["javascript"],"install":[{"cmd":"npm install run-queue","lang":"bash","label":"npm"},{"cmd":"yarn add run-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add run-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is CJS-only; no ESM exports.","wrong":"import RunQueue from 'run-queue'; // ESM not supported","symbol":"RunQueue","correct":"const RunQueue = require('run-queue')"},{"note":"Default import only; no named exports.","wrong":"import { RunQueue } from 'run-queue'; // named import not available","symbol":"RunQueue","correct":"import pkg from 'run-queue'; const RunQueue = pkg; // or const { RunQueue } = require('run-queue')"},{"note":"RunQueue is a class, not a factory function.","wrong":"Queue is not exported; must instantiate RunQueue.","symbol":"queue","correct":"const { add, run } = require('run-queue'); // No, RunQueue is a class"}],"quickstart":{"code":"const RunQueue = require('run-queue');\n\nconst queue = new RunQueue({\n  maxConcurrency: 2,\n  Promise: require('bluebird') // optional custom Promise\n});\n\nlet completed = 0;\nconst log = (id) => new Promise((resolve) => {\n  setTimeout(() => {\n    completed++;\n    console.log(`Job ${id} done (${completed})`);\n    resolve();\n  }, 100);\n});\n\nqueue.add(0, log, ['A']);\nqueue.add(1, log, ['B']);  // B waits for A\nqueue.add(0, log, ['C']);  // C runs before B\n\nqueue.run().then(() => {\n  console.log('All done');\n}).catch(err => {\n  console.error('Queue failed:', err);\n});","lang":"javascript","description":"Creates a queue with concurrency 2, adds jobs at priorities 0 and 1, runs them, and logs completion."},"warnings":[{"fix":"Be mindful of dynamic job addition; plan priorities accordingly or avoid adding lower-priority jobs while higher priorities are running.","message":"Priority behavior: All jobs of a lower priority must finish before any jobs of a higher priority start. Adding new lower-priority jobs during higher-priority execution will cause the queue to switch back to lower priority, delaying higher-priority jobs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set `maxConcurrency` option when creating the queue.","message":"maxConcurrency: 1 is default. If you expect concurrent execution, you must explicitly set maxConcurrency > 1.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Return a Promise from your job function instead of calling a `next` callback.","message":"The callback-style `fn(args, next)` pattern is supported but deprecated. Use async functions returning Promises instead.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'1':62 '2.0.1':18 'ad':28,57 'allow':27 'back':49 'base':7 'complet':41 'concurr':13,60 'configur':59 'custom':64 'default':61 'depend':71 'dynam':8,47 'ensur':33 'execut':45 'higher':43 'implement':66 'integ':31 'javascript':72 'job':29,36,55 'lightweight':67 'limit':14 'lower':39,51 'mainten':25 'new':54 'node.js':16 'prioriti':9,32,40,44,52 'promis':6,65 'promise-bas':5 'queue':3,10 'receiv':22 'run':2 'run-queu':1 'runner':11 'runtim':70 'sporad':24 'stabl':20 'support':58 'switch':48 'version':17","created_at":"2026-06-07T12:59:11.893981+00:00","updated_at":"2026-06-07T12:59:11.893981+00:00","problems":[{"fix":"Use `new RunQueue(options)` to create the queue.","cause":"Queue not properly instantiated; missing `new` keyword.","error":"TypeError: queue.add is not a function"},{"fix":"Use dynamic import: `const RunQueue = (await import('run-queue')).default;`","cause":"Trying to use require in an ES module environment.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://npmjs.com/package/run-queue","github":"https://github.com/iarna/run-queue","docs":null,"changelog":null,"pypi":null,"npm":"run-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}