fix: allow reusing a pool after end - #3750
Draft
zfaustk wants to merge 2 commits into
Draft
Conversation
zfaustk
marked this pull request as draft
August 12, 2026 19:22
Contributor
Author
|
Taking this back to draft for now. I missed a couple of existing tests that still assumed |
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.
Fixes #3635.
Problem
pool.end()currently makes aPoolpermanently unusable. It can also resolve before asynchronous client close callbacks finish, and work already queued beforeend()may be dropped while the pool drains.That prevents a long-lived global pool reference from being safely drained and reused in serverless lifecycle hooks.
Fix
pool.end();end()has fully resolved, so the same instance can create fresh connections again;end()behavior.Tests
pg-poollifecycle tests: 6 passed, covering repeatedquery → end → query → end, drain-time rejection, delayed client shutdown, queued queries, and multiple idle clients;yarn lint;git diff --check.The complete database-backed
yarn testsuite was not run locally because this executor has no PostgreSQL service. A standard install also requires local libpq tooling that is unavailable here. The root TypeScript build was attempted after a frozen--ignore-scriptsinstall and stopped in unchangedpg-query-streamcode becausepg-cursortypes were not built in that nonstandard environment. The upstream Node/PostgreSQL matrix remains the full integration gate.Implementation and test preparation were assisted by Codex. No human-review claim is made.