{"id":48904,"library":"pg-job-queue","title":"pg-job-queue","description":"A job queue for Node.js based on PostgreSQL, allowing you to define job handlers and process jobs using a CLI tool. The package is at version 0.3.3, with infrequent releases. It supports custom log, error, and shutdown handlers but has limited documentation. It differs from alternatives like Bull or Bee by using PostgreSQL as the backing store, which may be beneficial for teams already using PostgreSQL.","status":"active","version":"0.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/jameshy/pg-job-queue","tags":["javascript","postgres","postgresql","job","queue"],"install":[{"cmd":"npm install pg-job-queue","lang":"bash","label":"npm"},{"cmd":"yarn add pg-job-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add pg-job-queue","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PostgreSQL client required for database operations","package":"pg","optional":false}],"imports":[{"note":"CJS only; no ESM support. Use require.","wrong":"import jobqueue from 'pg-job-queue'","symbol":"default","correct":"const jobqueue = require('pg-job-queue')"},{"note":"Named export available; avoid .default which is undefined.","wrong":"const JobQueue = require('pg-job-queue').default","symbol":"JobQueue","correct":"const { JobQueue } = require('pg-job-queue')"},{"note":"CLI is not published to npm as a bin, only inside package. Must reference via full path or node_modules/.bin","wrong":"npx process-job-queue","symbol":"process-job-queue CLI","correct":"node_modules/.bin/process-job-queue -f ./handlers.js -c postgres://..."}],"quickstart":{"code":"const jobqueue = require('pg-job-queue');\nconst queue = new jobqueue('postgres://postgres@localhost/my-job-queue');\nqueue.addJob({\n  type: 'sendmail.welcome',\n  data: {\n    toAddress: 'demo@example.com',\n    message: 'hello'\n  }\n});\n\n// handlers.js\nmodule.exports = {\n  sendmail: {\n    welcome: function(job) {\n      return Promise.resolve().then(() => job.finish());\n    }\n  }\n};\n\n// Run with: node_modules/pg-job-queue/bin/process-job-queue -f ./handlers.js -c postgres://postgres@localhost/my-job-queue","lang":"javascript","description":"Creates a job queue instance, adds a job, defines a handler module, and runs the CLI processing loop."},"warnings":[{"fix":"Ensure job type uses dots to match nested handler path.","message":"Handler must be nested to match job type with dots (e.g., 'sendmail.welcome' maps to exports.sendmail.welcome).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use node_modules/pg-job-queue/bin/process-job-queue or add a script in package.json.","message":"CLI does not have a bin entry; must be run from node_modules/.bin directory.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use require() instead of import.","message":"No ESM support; using import will throw error.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure every handler calls job.finish() (or returns promise that resolves after finish).","message":"The job.finish() must be called explicitly; otherwise job remains pending.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Provide a valid connection string like postgres://user:password@host/db","message":"PostgreSQL connection string must be valid; no default provided.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.3.3':31 'allow':13 'alreadi':68 'altern':50 'back':60 'base':10 'bee':54 'benefici':65 'bull':52 'cli':24 'custom':37 'defin':16 'differ':48 'document':46 'error':39 'handler':18,42 'infrequ':33 'javascript':71 'job':3,6,17,21,74 'like':51 'limit':45 'log':38 'may':63 'node.js':9 'packag':27 'pg':2 'pg-job-queu':1 'postgr':72 'postgresql':12,57,70,73 'process':20 'queue':4,7,75 'releas':34 'shutdown':41 'store':61 'support':36 'team':67 'tool':25 'use':22,56,69 'version':30","created_at":"2026-06-07T16:59:03.608398+00:00","updated_at":"2026-06-07T16:59:03.608398+00:00","problems":[{"fix":"Run npm install pg-job-queue","cause":"Package not installed or missing from node_modules.","error":"Error: Cannot find module 'pg-job-queue'"},{"fix":"Use const jobqueue = require('pg-job-queue');","cause":"Using ES6 import instead of require or named import incorrectly.","error":"TypeError: jobqueue is not a constructor"},{"fix":"Export a nested object matching the dotted job type; e.g., exports.sendmail.welcome","cause":"Handler module does not export a function matching the job type hierarchy.","error":"Error: No handler defined for job type <type>"}],"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/jameshy/pg-job-queue#readme","github":"https://github.com/jameshy/pg-job-queue","docs":null,"changelog":null,"pypi":null,"npm":"pg-job-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"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}}