Repository navigation
fix(test): close leaked database pools in server/tests - #796
Open
adamsiwiec1 wants to merge 1 commit into
Open
adamsiwiec1 wants to merge 1 commit into
adamsiwiec1 wants to merge 1 commit into
Conversation
55 files on main opened a createDatabase pool and never gave it back; with TEST_POOL max: 2 that sits against PostgreSQL's 100-connection ceiling and makes the next integration tests fail with "too many clients already". - Close each formerly leaking pool with await database.$client.close() in a trailing afterAll so Bun's FIFO hooks run cleanup before the close. - Add database-pool-pairing.test.ts so a file that opens a database must close it. - Restore scripts/test-server-sharded.ts (was on arcade-provider, missing from main) with prose corrected: exhaustion tracks files that have run, and closing pools is the right fix; sharding stays for wall-clock. Fixes CopilotKit#785
adamsiwiec1
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
October 15, 2026 15:21
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
Fixes #785 —
server/testsfiles that open acreateDatabasepool must give it back.On
main, ~98 files open a pool and only 43 called$client.close(). The other pools stay open for the wholebun testprocess. WithTEST_POOL(max: 2), that sits against PostgreSQL's default 100-connection ceiling, so the next integration tests added fail withsorry, too many clients alreadyfor reasons unrelated to their change (as seen on #770).What changed
Close the remaining leaks. For each file that called
createDatabaseand never closed, added a trailing:Registered last so Bun's FIFO
afterAllorder runs that file's cleanup deletes before the close. Matches the idiom already used inidentity-store.integration.test.ts. Files that already used$client.end()were left alone (they already release the pool).Guard test
server/tests/database-pool-pairing.test.ts: any file that containscreateDatabase(must also contain$client.close(or$client.end(. Pairing rule rather than a lint rule, as proposed in the issue.Sharded runner prose.
scripts/test-server-sharded.tswas not onmain(it lives onarcade-provider). Restored it withtest:server:shardedand corrected the two misleading claims: slots are not exhausted "during the import phase", and the ceiling is not "never a reason to change source". Construction opens 0 connections; the first query takes the pool'smax; closing pools is the right fix. Sharding remains useful for wall-clock.Counts
closenorend)package.jsonscript$client.end()unchangedTest plan
bun test server/tests/database-pool-pairing.test.ts(pass)bun test server/tests/database.test.ts(pass)bun test server/tests/test:server:shardedwithTEST_DATABASE_URL(needs Postgres; not run in this environment)testsjob on this PR