Skip to content

Fix: disconnect correct client instance in zod test finally block#2415

Merged
ymc9 merged 2 commits intodevfrom
copilot/sub-pr-2414
Feb 27, 2026
Merged

Fix: disconnect correct client instance in zod test finally block#2415
ymc9 merged 2 commits intodevfrom
copilot/sub-pr-2414

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

In the can be constructed directly from client test, the const client declared inside the try block is not accessible in finally due to JS block scoping — so client.$disconnect() in finally was silently closing the outer beforeEach client instead, leaving the locally created client open.

Change

  • Rename the inner variable to localClient and hoist it above the try block so finally closes the correct instance
// Before: inner `client` shadows outer, but isn't accessible in `finally`
try {
    const client = await createTestClient(schema); // ← not in scope below
    ...
} finally {
    await client.$disconnect(); // ← closes the *outer* beforeEach client
}

// After
const localClient = await createTestClient(schema);
try {
    ...
} finally {
    await localClient.$disconnect(); // ← closes the correct instance
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback from review on merging dev to main Fix: disconnect correct client instance in zod test finally block Feb 27, 2026
@ymc9 ymc9 marked this pull request as ready for review February 27, 2026 19:21
@ymc9 ymc9 merged commit e5e452c into dev Feb 27, 2026
9 of 10 checks passed
@ymc9 ymc9 deleted the copilot/sub-pr-2414 branch February 27, 2026 19:36
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.

2 participants