Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(logs): treat an ended Postgres pool as a dependency failure (#100345)

Frank Hamand1a7c14c16fc4
diff --git a/nodejs/src/common/utils/db/postgres.test.ts b/nodejs/src/common/utils/db/postgres.test.ts
index b6a666134c70..ee0f25fdb99b 100644
--- a/nodejs/src/common/utils/db/postgres.test.ts
+++ b/nodejs/src/common/utils/db/postgres.test.ts
@@ -6,6 +6,7 @@ describe('transient postgres error classification', () => {
['connect ECONNREFUSED 10.0.0.1:6543', true],
['connect EHOSTUNREACH 10.0.0.1:6543', true],
['pooler is shutting down', true],
+ ['Cannot use a pool after calling end on the pool', true],
['server conn crashed?', true],
['duplicate key value violates unique constraint', false],
['syntax error at or near "SELCT"', false],
diff --git a/nodejs/src/common/utils/db/postgres.ts b/nodejs/src/common/utils/db/postgres.ts
index 3d672aecff93..857e65cfa14f 100644
--- a/nodejs/src/common/utils/db/postgres.ts
+++ b/nodejs/src/common/utils/db/postgres.ts
@@ -57,6 +57,7 @@ const POSTGRES_UNAVAILABLE_ERROR_MESSAGES = [
'query_wait_timeout', // Waiting on PG bouncer to give us a slot
'server login has been failing', // PgBouncer cannot authenticate with upstream PG
'pooler is shutting down', // PgBouncer terminating client connections during a restart
+ 'Cannot use a pool after calling end on the pool', // Shutdown ended the pool while work was still in flight
]
export function isTransientPgError(err: unknown): boolean {