Repository navigation
Conversation
karenc-bq
marked this pull request as ready for review
November 25, 2026 11:55
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
feat: connection lifetime plugin
Description
Issue. The wrapper has no way to limit how long a client keeps using one physical connection, so a long-lived client stays on the same server session and host indefinitely.
Fix. Adds the
connectionLifetimeplugin, configured with the requiredconnectionLifetimeMsandconnectionLifetimeAction(reconnectby default, orclose). When an expired connection makes a network-bound call, the plugin acts before the call runs. Withcloseit closes the connection and throwsConnectionLifetimeError. Withreconnectit opens a replacement to the original host and throwsConnectionLifetimeSuccessError. The pending call does not run, and the plugin takes no action inside a transaction. With the AWS pool clients or internal connection pooling, the expired connection is also removed from its pool so it is not handed out again.Impact. Opt-in only.
ConnectionLifetimeSuccessErrorextendsFailoverSuccessError, so code that already retries after a failover also retries after a reconnect. A failed reconnect throwsConnectionLifetimeFailedErrorwith the original failure ascause.Scope. The plugin times a pooled connection from when the client takes it from the pool. To bound the age of the physical connection, use the pool's own settings, as the new docs page explains.
Verification.
connection_lifetime_plugin.test.ts,internal_pool_eviction.test.tsandconnection_plugin_chain_builder.test.tscover both actions, transaction deferral, failed reconnects, eviction and plugin ordering. After rebasing ontomain,tsc --noEmit, prettier, eslint and the full unit suite (881 tests) pass.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.