Skip to content

fix(pg): prevent process crash during Aurora failover#621

Open
azihsoyn wants to merge 1 commit intoaws:mainfrom
azihsoyn:fix/pg-failover-crash
Open

fix(pg): prevent process crash during Aurora failover#621
azihsoyn wants to merge 1 commit intoaws:mainfrom
azihsoyn:fix/pg-failover-crash

Conversation

@azihsoyn
Copy link

@azihsoyn azihsoyn commented Mar 5, 2026

Summary

resolve #620

Description

Two issues cause Node.js process to crash when an Aurora failover occurs:

  1. AwsPgInternalPoolClient creates a pg.Pool without an 'error' event handler. During failover, idle connections are terminated by the server, emitting 'error' events on the pool. Without a handler, Node.js throws an uncaught exception and the process exits.

  2. AwsPGPooledConnection.release() unconditionally calls this.targetClient.client.release(), but after failover the new client may not have a release() method (e.g., a direct connection rather than a pooled connection), causing a TypeError.

Fix 1: Attach a no-op 'error' handler to the internal pg.Pool so idle connection errors are swallowed. The failover plugin handles reconnection.

Fix 2: Check if release() exists on the underlying client before calling it.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Two issues cause Node.js process to crash when an Aurora failover occurs:

1. AwsPgInternalPoolClient creates a pg.Pool without an 'error' event
   handler. During failover, idle connections are terminated by the
   server, emitting 'error' events on the pool. Without a handler,
   Node.js throws an uncaught exception and the process exits.

2. AwsPGPooledConnection.release() unconditionally calls
   this.targetClient.client.release(), but after failover the new
   client may not have a release() method (e.g., a direct connection
   rather than a pooled connection), causing a TypeError.

Fix 1: Attach a no-op 'error' handler to the internal pg.Pool so idle
connection errors are swallowed. The failover plugin handles
reconnection.

Fix 2: Check if release() exists on the underlying client before
calling it.
@azihsoyn azihsoyn requested a review from a team as a code owner March 5, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Process crashes after Aurora failover with pg (node-postgres) driver - two issues

1 participant