File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -358,7 +358,11 @@ class AwsPGPooledConnection extends BaseAwsPgClient {
358358 throw new UndefinedClientError ( ) ;
359359 }
360360 this . pluginService . removeErrorListener ( this . targetClient ) ;
361- return await this . targetClient . client . release ( ) ;
361+ // After failover, the new target client may not have a release() method
362+ // (e.g., a direct connection instead of a pooled connection).
363+ if ( typeof this . targetClient . client ?. release === "function" ) {
364+ return await this . targetClient . client . release ( ) ;
365+ }
362366 } ,
363367 null
364368 ) ;
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ export class AwsPgInternalPoolClient implements AwsInternalPoolClient {
2525
2626 constructor ( props : pkgPg . PoolConfig ) {
2727 this . targetPool = new pkgPg . Pool ( props ) ;
28+ // Handle idle client errors to prevent process crash during Aurora failover.
29+ // When a failover occurs, idle connections in the pool are terminated by the server,
30+ // which emits 'error' events. Without this handler, Node.js throws an uncaught exception.
31+ this . targetPool . on ( "error" , ( ) => {
32+ // Intentionally swallowed. The failover plugin will handle reconnection.
33+ } ) ;
2834 }
2935
3036 async end ( ) : Promise < any > {
You can’t perform that action at this time.
0 commit comments