{"id":45995,"library":"queue","title":"queue","description":"Asynchronous function queue with adjustable concurrency. Version 7.0.0. Allows controlling the number of concurrently running async jobs, with support for timeouts, event listeners, and array-like API (push, unshift, splice, etc.). Jobs can use callbacks or return promises. Ships TypeScript types. Maintained actively on GitHub.","status":"active","version":"7.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/jessetane/queue","tags":["javascript","queue","async","asynchronous","synchronous","job","task","concurrency","concurrent","typescript"],"install":[{"cmd":"npm install queue","lang":"bash","label":"npm"},{"cmd":"yarn add queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export; named import will fail. TypeScript types support default import.","wrong":"import { Queue } from 'queue'","symbol":"Queue","correct":"import Queue from 'queue'"},{"note":"CommonJS: require returns the class directly, not an object.","wrong":"const { Queue } = require('queue')","symbol":"Queue","correct":"const Queue = require('queue')"},{"note":"Namespace import not valid; default import is correct.","wrong":"import * as Queue from 'queue'","symbol":"Queue","correct":"import Queue from 'queue'"}],"quickstart":{"code":"import Queue from 'queue'\n\nconst q = new Queue({ concurrency: 2, autostart: true })\n\nq.push(cb => {\n  setTimeout(() => {\n    console.log('job 1')\n    cb()\n  }, 100)\n})\n\nq.push(() => {\n  return new Promise(resolve => {\n    setTimeout(() => {\n      console.log('job 2')\n      resolve()\n    }, 200)\n  })\n})\n\nq.push(cb => {\n  setTimeout(() => {\n    console.log('job 3')\n    cb()\n  }, 50)\n})\n\n// Wait for all jobs to finish\nq.start(err => {\n  if (err) throw err\n  console.log('all done')\n})","lang":"javascript","description":"Creates a queue with concurrency 2, adds three jobs (callback and promise style), and starts processing."},"warnings":[{"fix":"Use import or upgrade to Node >=12 with type:module in package.json, or use bundler like Webpack/Rollup.","message":"Since v6, the package is ESM-only. require() will fail in Node < 12 or without bundler.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Listen to 'end' event for completion and check error parameter, or use promise returned by start().","message":"Event names 'success' and 'error' have been deprecated since v6. Use 'end' and 'error' instead.","severity":"deprecated","affected_versions":">=6.0.0 <7.0.0"},{"fix":"Use q.toArray() or manually copy the array if you need an independent copy.","message":"q.slice() does not copy the queue; it returns a shallow slice of the queue's internal array, but modifying it will affect the original queue.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Either always use callback or always use .then().catch() on the returned promise.","message":"q.start() returns a promise if no callback is provided. Mixing callback and promise patterns can lead to unhandled rejections.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Set timeout as a property on the job function itself.","message":"In v7, the 'timeout' property on a job must be set directly on the function (e.g., job.timeout = 100). Passing options in an object is no longer supported.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Use only one completion mechanism per job.","message":"Jobs that return a promise and also call a callback may cause double resolution. The queue resolves on the first completion (callback or promise).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'7.0.0':9 'activ':45 'adjust':6 'allow':10 'api':29 'array':27 'array-lik':26 'async':17,50 'asynchron':2,51 'callback':37 'concurr':7,15,55,56 'control':11 'etc':33 'event':23 'function':3 'github':47 'javascript':48 'job':18,34,53 'like':28 'listen':24 'maintain':44 'number':13 'promis':40 'push':30 'queue':1,4,49 'return':39 'run':16 'ship':41 'splice':32 'support':20 'synchron':52 'task':54 'timeout':22 'type':43 'typescript':42,57 'unshift':31 'use':36 'version':8","created_at":"2026-06-07T12:57:45.472633+00:00","updated_at":"2026-06-07T12:57:45.472633+00:00","problems":[{"fix":"Use `import Queue from 'queue'`.","cause":"Using named import `import { Queue } from 'queue'` instead of default import.","error":"TypeError: queue_1.default is not a constructor"},{"fix":"Use import or compile with bundler (Webpack/Rollup).","cause":"Using require() on an ESM-only module (v6+).","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/node_modules/queue/index.js from /path/file.js not supported."},{"fix":"Increase timeout or set per-job timeout via job.timeout property.","cause":"Timeout default or set too low; job did not complete in time.","error":"TimeoutError: Job timed out after 100ms"},{"fix":"Ensure each pushed item is a function that accepts a callback or returns a promise.","cause":"Adding non-function items to the queue (e.g., objects, strings).","error":"job is not a function"}],"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://github.com/jessetane/queue#readme","github":"https://github.com/jessetane/queue","docs":null,"changelog":null,"pypi":null,"npm":"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}}