High-Availability wrapper over node-postgres (pg) that enhances Pool resilience by addressing common issues like unreleased clients after network failures, inability to detect disconnections, client references remaining usable after release, pool.end() hanging, and query cancellation after reconnection. Current version 0.0.9, actively developed. Differentiators include auto-recovery, connection monitoring, client timeout for forced pool end, and remote query cancellation. Requires node-postgres as a peer dependency.
npm install ha-pgNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a high-availability Pool with autoRecover and client_timeout, run a query, then cleanly shut down.
npm install ha-pg pg
Use original pg for Client operations.
Set to 0 or omit if unintended termination is not desired.
Disable autoCancel if not needed.
Use async/await or .then() patterns.
Ensure PostgreSQL is started and connection parameters are correct.
const { Pool } = require('ha-pg');Ensure each client is released exactly once; use try/finally blocks.
Import Pool from 'ha-pg'.