You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pool.end() currently makes a Pool permanently unusable. It can also resolve before asynchronous client close callbacks finish, and work already queued before end() 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
wait for every client close callback before resolving pool.end();
finish requests that were already queued when draining began, while continuing to reject new checkouts during the drain;
reset the pool lifecycle only after end() has fully resolved, so the same instance can create fresh connections again;
The complete database-backed yarn test suite 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-scripts install and stopped in unchanged pg-query-stream code because pg-cursor types 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.
Taking this back to draft for now. I missed a couple of existing tests that still assumed pool.end() made the pool unusable; those tests held checked-out clients and caused the first matrix run to hang. I updated them, and 10 of 11 matrix jobs now pass, but the Node 24 job still exits with code 139 in a pg-native load test. I also want to understand how this fits with the pool work in #3739 before asking for review. I’ll keep digging and mark it ready again only when the matrix is clean and that overlap is clear. Sorry—I put this in the review queue too soon.
k - thanks for the PR tho! I agree reusing a pool might be nice in certain situations - particularly things like "I want to wait for this pool to fully drain, then and only then it can be reused" for serverless style environments. I re-triggered the tests here as the matrix failed AFAICT because of a segfault related to GH infra. LMK when you want a review!
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
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.