fix: honour DISABLE_TIMEOUT for idleTimeout and maximumConnectionAge#764
Merged
fix: honour DISABLE_TIMEOUT for idleTimeout and maximumConnectionAge#764
Conversation
Previously, passing idleTimeout: 'DISABLE_TIMEOUT' was silently ignored because createPoolConfiguration skipped the assignment when the value was the sentinel string, leaving the internal number field at its 10_000ms default. The idle timer then fired as normal. - Widen PoolConfiguration.idleTimeout to 'DISABLE_TIMEOUT' | number - Pass the sentinel string through createPoolConfiguration instead of skipping it - Guard setIdleTimer in createConnectionPool with an early return when idleTimeout === 'DISABLE_TIMEOUT' - Update createTestPool helper to accept the widened type - Add test: idle timeout is disabled when idleTimeout is DISABLE_TIMEOUT Made-with: Cursor
maximumConnectionAge previously only accepted a number, providing no way to opt out of age-based connection recycling. This adds 'DISABLE_TIMEOUT' as an accepted value, consistent with connectionTimeout, statementTimeout, and idleInTransactionSessionTimeout. - Widen ClientConfiguration.maximumConnectionAge to 'DISABLE_TIMEOUT' | number in types.ts - Widen PoolConfiguration.maximumConnectionAge and pass the sentinel string through createPoolConfiguration - In createConnectionPool, set effectiveMaxAge to Infinity when maximumConnectionAge is 'DISABLE_TIMEOUT' so isConnectionTooOld always returns false - Update createTestPool helper to accept the widened type - Add test: connection is not destroyed when maximumConnectionAge is DISABLE_TIMEOUT Made-with: Cursor
Passing maximumConnectionAge: 0 was silently ignored due to a falsy check, leaving the 30-minute default in place. This mirrors the existing idleTimeout=0 handling: warn the caller and clamp to 1ms. Also adds a createPoolConfiguration unit test file covering all four cases for both maximumConnectionAge and idleTimeout (0, positive number, DISABLE_TIMEOUT, undefined/default). Made-with: Cursor
- Map 'DISABLE_TIMEOUT' to Number.POSITIVE_INFINITY in createPoolConfiguration so createConnectionPool works with plain numeric comparisons throughout - Remove 'DISABLE_TIMEOUT' | number union from createConnectionPool parameter types; idleTimeout and maximumConnectionAge are now plain numbers - Replace string sentinel guard in setIdleTimer with Number.isFinite check - Simplify effectiveMaxAge computation — Infinity * jitter_factor = Infinity, so no special case needed for the disabled state - Widen DriverConfiguration.maximumConnectionAge to 'DISABLE_TIMEOUT' | number in @slonik/driver, consistent with other timeout fields; add temporary cast in createPool.ts until the package is republished - Extract resolveTestTimeout helper in createConnectionPool.test.ts to map 'DISABLE_TIMEOUT' to Infinity before passing to createConnectionPool - Add createPoolConfiguration unit tests covering all input cases for both idleTimeout and maximumConnectionAge - Add changeset Made-with: Cursor
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.
#763