{"id":46670,"library":"ts-fork-queue","title":"ts-fork-queue","description":"A minimalistic Node.js fork queue that schedules enqueued tasks and runs them in separate child processes using child_process.fork(). Version 0.1.34 is the latest stable release, with no active release cadence. Key differentiators: TypeScript-first, configurable queue size and parallelism, polling-based scheduler. Limited to forking Node.js modules; tasks must self-terminate via process.exit().","status":"active","version":"0.1.34","language":"javascript","source_language":"en","source_url":"https://github.com/thornberger/fork-queue","tags":["javascript","fork","queue","typescript","nodejs"],"install":[{"cmd":"npm install ts-fork-queue","lang":"bash","label":"npm"},{"cmd":"yarn add ts-fork-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add ts-fork-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM named export. CommonJS require will not work because the package is ESM-only.","wrong":"const ForkQueue = require('ts-fork-queue')","symbol":"ForkQueue","correct":"import { ForkQueue } from 'ts-fork-queue'"},{"note":"Class thrown when enqueuing to a full queue.","symbol":"QueueFullError","correct":"import { QueueFullError } from 'ts-fork-queue'"},{"note":"Class thrown when an invalid configuration object is passed to ForkQueue constructor.","symbol":"InvalidConfigError","correct":"import { InvalidConfigError } from 'ts-fork-queue'"}],"quickstart":{"code":"import { ForkQueue } from 'ts-fork-queue';\nimport { resolve } from 'path';\n\nconst queue = new ForkQueue({\n  maxQueueSize: 5,\n  maxParallelism: 2,\n  pollingPeriodSeconds: 1\n});\n\nqueue.start();\n\nconst task = {\n  getCommand: () => resolve(__dirname, './worker.js'),\n  getArgs: () => '--port=3000',\n  getCwd: () => __dirname,\n  toString: () => 'worker'\n};\n\ntry {\n  queue.enqueue(task);\n} catch (err) {\n  if (err instanceof (await import('ts-fork-queue')).QueueFullError) {\n    console.error('Queue is full');\n  }\n}\n// Worker script (worker.js): process.exit(0) after work is done.","lang":"typescript","description":"Creates a ForkQueue with max 5 queued tasks and 2 parallel processes, starts the scheduler, and enqueues a task that forks a Node.js worker module."},"warnings":[{"fix":"Ensure each forked module calls process.exit() after completing its work, or the process will hang until the parent dies.","message":"Tasks must call process.exit() to terminate; the queue does not kill child processes when the root process exits.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Wrap enqueue() in a try-catch block to handle queue full conditions.","message":"enqueue() throws QueueFullError if the queue is at max capacity. The error is not returned, it must be caught with try/catch.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure maxQueueSize >= 1, maxParallelism >= 1, pollingPeriodSeconds > 0.","message":"Configuration validation is strict; invalid values throw InvalidConfigError at construction time.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use a reasonable polling interval, e.g. 2 seconds, to avoid excessive CPU load.","message":"Polling period uses seconds, not milliseconds. Setting pollingPeriodSeconds too low (<0.1) may cause high CPU usage.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.34':24 'activ':32 'base':47 'cadenc':34 'child':19 'child_process.fork':22 'configur':40 'differenti':36 'enqueu':12 'first':39 'fork':3,8,51,62 'javascript':61 'key':35 'latest':27 'limit':49 'minimalist':6 'modul':53 'must':55 'node.js':7,52 'nodej':65 'parallel':44 'poll':46 'polling-bas':45 'process':20 'process.exit':60 'queue':4,9,41,63 'releas':29,33 'run':15 'schedul':11,48 'self':57 'self-termin':56 'separ':18 'size':42 'stabl':28 'task':13,54 'termin':58 'ts':2 'ts-fork-queu':1 'typescript':38,64 'typescript-first':37 'use':21 'version':23 'via':59","created_at":"2026-06-07T13:01:03.805899+00:00","updated_at":"2026-06-07T13:01:03.805899+00:00","problems":[{"fix":"npm install ts-fork-queue","cause":"Package not installed.","error":"Cannot find module 'ts-fork-queue'"},{"fix":"Use import { ForkQueue } from 'ts-fork-queue' or enable ESM in your project.","cause":"Using CommonJS require on an ESM-only package.","error":"ForkQueue is not a constructor"},{"fix":"Provide an object with all four methods returning strings.","cause":"Task object does not implement the required interface (missing getCommand, getArgs, getCwd, toString).","error":"TypeError: task.getCommand 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/thornberger/fork-queue","github":"https://github.com/thornberger/fork-queue","docs":null,"changelog":null,"pypi":null,"npm":"ts-fork-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}}