Skip to content

feat: connection lifetime plugin - #723

Open
karenc-bq wants to merge 1 commit into
mainfrom
feat/connection-lifetime-plugin
Open

karenc-bq wants to merge 1 commit into
mainfrom
feat/connection-lifetime-plugin

Conversation

@karenc-bq

Copy link
Copy Markdown
Contributor

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 connectionLifetime plugin, configured with the required connectionLifetimeMs and connectionLifetimeAction (reconnect by default, or close). When an expired connection makes a network-bound call, the plugin acts before the call runs. With close it closes the connection and throws ConnectionLifetimeError. With reconnect it opens a replacement to the original host and throws ConnectionLifetimeSuccessError. 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. ConnectionLifetimeSuccessError extends FailoverSuccessError, so code that already retries after a failover also retries after a reconnect. A failed reconnect throws ConnectionLifetimeFailedError with the original failure as cause.

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.ts and connection_plugin_chain_builder.test.ts cover both actions, transaction deferral, failed reconnects, eviction and plugin ordering. After rebasing onto main, 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.

@karenc-bq
karenc-bq marked this pull request as ready for review November 25, 2026 11:55
@karenc-bq
karenc-bq requested a review from a team as a code owner November 25, 2026 11:55

This branch has not been deployed

No deployments
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.

1 participant