PostgreSQL error 57P01 (terminating connection due to administrator command) is emitted as an error event on the pg.Pool when an idle pooled client is killed (server restart, pg_terminate_backend, or admin command).
Both attachRealtime (API) and createRemoteBroadcaster (ingest worker) created pg.Pool instances without an error listener. With no listener, Node treats the event as an uncaughtException and crashes the process — exactly the uncaught: true report in BIT-32447.
Fix
Add pool.on("error", ...) handlers that forward to onError and skip pool-after-end noise during shutdown, mirroring the existing client.on("error") reconnection logic for the LISTEN client.
Test
New regression test does not crash when Postgres terminates an idle pooled connection (BIT-32447): publishes once to establish the pool connection, terminates the idle backend via pg_terminate_backend (simulating the admin command), then asserts no uncaughtException fires, onError receives the terminating connection error, and a subsequent publish recovers on a fresh connection. Verified the test fails (uncaughtException) without the fix and passes with it.
## Root cause
PostgreSQL error `57P01` (`terminating connection due to administrator command`) is emitted as an `error` event on the `pg.Pool` when an idle pooled client is killed (server restart, `pg_terminate_backend`, or admin command).
Both `attachRealtime` (API) and `createRemoteBroadcaster` (ingest worker) created `pg.Pool` instances **without** an `error` listener. With no listener, Node treats the event as an `uncaughtException` and crashes the process — exactly the `uncaught: true` report in BIT-32447.
## Fix
Add `pool.on("error", ...)` handlers that forward to `onError` and skip `pool-after-end` noise during shutdown, mirroring the existing `client.on("error")` reconnection logic for the LISTEN client.
## Test
New regression test `does not crash when Postgres terminates an idle pooled connection (BIT-32447)`: publishes once to establish the pool connection, terminates the idle backend via `pg_terminate_backend` (simulating the admin command), then asserts no `uncaughtException` fires, `onError` receives the `terminating connection` error, and a subsequent publish recovers on a fresh connection. Verified the test fails (uncaughtException) without the fix and passes with it.
Paperclip-Issue: BIT-32447
Paperclip-Cluster: 52b3174b839d
PostgreSQL error 57P01 (terminating connection due to administrator command)
is emitted as an 'error' event on the pg.Pool when an idle pooled client is
killed. Both attachRealtime (API) and createRemoteBroadcaster (ingest worker)
created pools without an 'error' listener, so Node treated it as an
uncaughtException and crashed the process. Add pool.on('error') handlers that
forward to onError (and skip noise during shutdown), mirroring the existing
client.on('error') reconnection logic.
Paperclip-Issue: BIT-32447
Paperclip-Cluster: 52b3174b839d
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Root cause
PostgreSQL error
57P01(terminating connection due to administrator command) is emitted as anerrorevent on thepg.Poolwhen an idle pooled client is killed (server restart,pg_terminate_backend, or admin command).Both
attachRealtime(API) andcreateRemoteBroadcaster(ingest worker) createdpg.Poolinstances without anerrorlistener. With no listener, Node treats the event as anuncaughtExceptionand crashes the process — exactly theuncaught: truereport in BIT-32447.Fix
Add
pool.on("error", ...)handlers that forward toonErrorand skippool-after-endnoise during shutdown, mirroring the existingclient.on("error")reconnection logic for the LISTEN client.Test
New regression test
does not crash when Postgres terminates an idle pooled connection (BIT-32447): publishes once to establish the pool connection, terminates the idle backend viapg_terminate_backend(simulating the admin command), then asserts nouncaughtExceptionfires,onErrorreceives theterminating connectionerror, and a subsequent publish recovers on a fresh connection. Verified the test fails (uncaughtException) without the fix and passes with it.Paperclip-Issue: BIT-32447
Paperclip-Cluster: 52b3174b839d
PostgreSQL error 57P01 (terminating connection due to administrator command) is emitted as an 'error' event on the pg.Pool when an idle pooled client is killed. Both attachRealtime (API) and createRemoteBroadcaster (ingest worker) created pools without an 'error' listener, so Node treated it as an uncaughtException and crashed the process. Add pool.on('error') handlers that forward to onError (and skip noise during shutdown), mirroring the existing client.on('error') reconnection logic. Paperclip-Issue: BIT-32447 Paperclip-Cluster: 52b3174b839d5be8e8aafeto4a7dba5480auto-approve: CI success on
4a7dba5480(gitea_auto_approve_open_prs_once.py)auto-approve: CI success on
4a7dba5480(gitea_auto_approve_open_prs_once.py)auto-approve: CI success on
4a7dba5480(gitea_auto_approve_open_prs_once.py)