Registry / storage / postgres-queue

postgres-queue

JSON →
library1.3.2jsnpmunverified

Postgres-queue (v1.3.2) is a PostgreSQL-backed request-response queue for Node.js, designed for reliable message passing with at-least-once delivery guarantees. It uses PostgreSQL as its storage backend, leveraging its transactional semantics for durability and visibility. The library provides a simple API for enqueuing and dequeuing messages, with support for visibility timeouts, retries, and dead-letter handling. Differentiates from in-memory queues (e.g., Bull) by persisting state in PostgreSQL without additional infrastructure like Redis, making it attractive for projects already using Postgres. Release cadence is ad-hoc; maintained by Growmies.

npm install postgres-queue
INSTALL
IMPORT
SIG · POSTGRES-QUEUE
P
postgres-queue
storagejavascriptv1.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Queue
import { Queue } from 'postgres-queue'
const Queue = require('postgres-queue')
Library is ESM-only; CommonJS require will fail.
PostgresQueue
import { PostgresQueue } from 'postgres-queue'
import { PostgresQueue } from 'postgres-queue'; // Not exported, use Queue
Only Queue class is exported; PostgresQueue is not a valid symbol.
types
import type { QueueOptions } from 'postgres-queue'
import { QueueOptions } from 'postgres-queue'
Types are not runtime values; use import type for TypeScript.

Creates a PostgreSQL-backed queue, enqueues a message, dequeues it, processes, and deletes.

import { Queue } from 'postgres-queue'; const queue = new Queue({ connectionString: process.env.DATABASE_URL ?? 'postgres://localhost:5432/mydb', schema: 'public', tableName: 'my_queue' }); async function main() { await queue.createTable(); // Enqueue a message const id = await queue.enqueue({ type: 'greeting', payload: { text: 'Hello!' } }); console.log('Enqueued message ID:', id); // Dequeue a message const msg = await queue.dequeue({ visibilityTimeout: 30 }); if (msg) { console.log('Got message:', msg.payload); await queue.delete(msg.id); } await queue.end(); } main().catch(console.error);
Debug
Known issues
gotchaCalling createTable() is required before enqueue/dequeue or operations will fail with 'relation does not exist'.
fix
Always await queue.createTable() after instantiating the queue.
affects: >=1.0.0
breakingIn version 1.0.0, the export changed from default export (class Queue) to named export. Previous import `import Queue from 'postgres-queue'` will break.
fix
Use named import: `import { Queue } from 'postgres-queue'`.
affects: <1.0.0
breakingVersion 1.3.0 dropped support for Node.js < 14. Using on older Node versions may cause ERR_REQUIRE_ESM errors.
fix
Upgrade Node.js to version 14 or higher.
affects: <14.0.0
Errors
Common errors & fixes
Error: relation "my_queue" does not exist
The queue table hasn't been created yet; createTable() was not called.
fix
Add await queue.createTable() after queue instantiation.
ERR_REQUIRE_ESM
Using require() on an ESM-only module.
fix
Use import syntax or set type: module in package.json.
TypeError: queue.enqueue is not a function
Importing the wrong symbol (e.g., PostgresQueue) or default import on old version.
fix
Use import { Queue } from 'postgres-queue'.
Upgrade
Version history
1.3.2latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client driver required for database operations
uuidrequiredUsed for generating unique message IDs
Agent activity
28 hits · last 30 days
node
26
Amazon
1
OpenAI (training)
1
Resources
postgres-queue — npm install postgres-queue · libregistry