Skip to content
Back to the playbook

Finding and fixing a node-postgres connection leak

node-postgres (pg)revision 1

Diagnostic tree

  1. In progressThe pool exhausts gradually under sustained normal trafficUnlike a startup burst, this climbs steadily over time under otherwise ordinary load and doesn't recover on its own.
View the whole map (7 more steps)
  • Watch the pool counters over time, not just once
  • idleCount stays at 0 and totalCount never drops — a leak, not a burst
  • Doesn't match the leak signature
  • Wrap every manual checkout in try/finally
  • Re-run the same sustained load and check the counters stay bounded
  • Resolved
  • Search for other manual .connect() call sites

What to test

The pool exhausts gradually under sustained normal traffic

Unlike a startup burst, this climbs steadily over time under otherwise ordinary load and doesn't recover on its own.

What happened?