From 27af479d2fceac4f08e8620defda33d5ac465b48 Mon Sep 17 00:00:00 2001 From: Johan Fagerberg Date: Tue, 10 Jun 2025 10:11:31 +0200 Subject: [PATCH] docs: add `maxLifetimeSeconds` to Pool docs Wording taken from https://github.com/brianc/node-postgres/issues/3298#issuecomment-2305207256 --- docs/pages/apis/pool.mdx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/pages/apis/pool.mdx b/docs/pages/apis/pool.mdx index a94baed7c..608835fc6 100644 --- a/docs/pages/apis/pool.mdx +++ b/docs/pages/apis/pool.mdx @@ -50,6 +50,12 @@ type Config = { // to the postgres server. This can be handy in scripts & tests // where you don't want to wait for your clients to go idle before your process exits. allowExitOnIdle?: boolean + + // Sets a max overall life for the connection. + // A value of 60 would evict connections that have been around for over 60 seconds, + // regardless of whether they are idle. It's useful to force rotation of connection pools through + // middleware so that you can rotate the underlying servers. The default is disabled (value of zero) + maxLifetimeSeconds?: number } ``` @@ -64,6 +70,7 @@ const pool = new Pool({ max: 20, idleTimeoutMillis: 30000, connectionTimeoutMillis: 2000, + maxLifetimeSeconds: 60 }) ```