{"id":45287,"library":"lib-job-queue","title":"lib-job-queue","description":"A simple Node.js library for creating sequential job queues where each task is a child process. Version 2.1.0 is the latest stable release, with infrequent updates. It differentiates from other job queue libraries by focusing solely on child process execution in strict sequence, with built-in events (task, exit, end) and an abort mechanism that kills the current process (default SIGKILL).","status":"active","version":"2.1.0","language":"javascript","source_language":"en","source_url":"git://github.com/groundwater/node-lib-job-queue","tags":["javascript"],"install":[{"cmd":"npm install lib-job-queue","lang":"bash","label":"npm"},{"cmd":"yarn add lib-job-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add lib-job-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The module exports a factory function that must be called with parentheses to get a Job constructor.","wrong":"var jobQueue = require('lib-job-queue'); jobQueue();","symbol":"default (factory function)","correct":"var Job = require('lib-job-queue')();"},{"note":"Use Job.New() method to create a new job instance, not the new keyword.","wrong":"var job = new Job();","symbol":"Job.New()","correct":"var job = Job.New();"},{"note":"add() expects an object with exec, args, envs properties; positional arguments are not supported.","wrong":"job.add('ps', ['aux']);","symbol":"job.add()","correct":"job.add({ exec: 'ps', args: ['aux'], envs: process.env });"},{"note":"Events are emitted on the emitter property, not directly on the job object.","wrong":"job.on('task', callback);","symbol":"job.emitter","correct":"job.emitter.on('task', callback);"},{"note":"abort() kills the current child process with SIGKILL by default; you can pass a custom signal.","wrong":"job.abort('SIGTERM'); // valid but less common","symbol":"job.abort()","correct":"job.abort();"}],"quickstart":{"code":"var Job = require('lib-job-queue')();\n\nvar job = Job.New();\n\njob.add({\n  exec: 'echo',\n  args: ['Hello from job queue'],\n  envs: process.env\n});\n\njob.emitter.on('exit', function (status) {\n  console.log('Process exited with code:', status.code);\n});\n\njob.emitter.on('end', function () {\n  console.log('All tasks completed');\n});\n","lang":"javascript","description":"Creates a sequential job queue, adds a single echo task, and listens for exit and end events."},"warnings":[{"fix":"If you need graceful shutdown, pass a different signal like 'SIGTERM' to abort().","message":"The default kill signal for abort() is SIGKILL, which cannot be caught by the child process. This means the child process will be terminated immediately without cleanup.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Be careful about adding tasks after the queue has ended; consider resetting or managing state accordingly.","message":"Adding a job after an 'end' event triggers another 'end' event when that new job completes. This can cause unexpected event listener callbacks.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always include the parentheses: require('lib-job-queue')().","message":"The require function must be called immediately: var Job = require('lib-job-queue')(). Forgetting the initial call returns a function instead of a Job constructor.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Access job.current within a 'task' event handler or when you know a process is active.","message":"job.current is only available while a task is running; accessing it after the task completes returns undefined.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'2.1.0':22 'abort':58 'built':50 'built-in':49 'child':19,42 'creat':10 'current':63 'default':65 'differenti':32 'end':55 'event':52 'execut':44 'exit':54 'focus':39 'infrequ':29 'javascript':67 'job':3,12,35 'kill':61 'latest':25 'lib':2 'lib-job-queu':1 'librari':8,37 'mechan':59 'node.js':7 'process':20,43,64 'queue':4,13,36 'releas':27 'sequenc':47 'sequenti':11 'sigkil':66 'simpl':6 'sole':40 'stabl':26 'strict':46 'task':16,53 'updat':30 'version':21","created_at":"2026-06-07T12:54:17.167831+00:00","updated_at":"2026-06-07T12:54:17.167831+00:00","problems":[{"fix":"Change to require('lib-job-queue')() to get the constructor function.","cause":"Calling require('lib-job-queue') without the additional invocation parentheses, then using new Job().","error":"TypeError: Job is not a constructor"},{"fix":"Ensure you have created a job instance: var job = Job.New(); before using job.emitter.","cause":"Trying to access job.emitter before creating a job with Job.New().","error":"TypeError: job.emitter is undefined"},{"fix":"Provide an object with exec, args, envs: job.add({ exec: 'ls', args: ['-la'], envs: process.env });","cause":"Passing an object to job.add() without the exec property or with a non-string value.","error":"Error: exec must be a string"}],"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/groundwater/node-lib-job-queue","github":"git://github.com/groundwater/node-lib-job-queue","docs":null,"changelog":null,"pypi":null,"npm":"lib-job-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}}