Skip to content

fix: always disconnect the session after a test run #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/integration/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function setupIntegrationTest(getUserConfig: () => UserConfig): Integrati
});

afterEach(async () => {
if (mcpServer && !mcpServer.session.connectedAtlasCluster) {
if (mcpServer) {
await mcpServer.session.disconnect();
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling around the disconnect operation to prevent test failures if disconnection throws an exception. The current implementation could cause afterEach to fail and potentially leave resources in an inconsistent state.

Suggested change
await mcpServer.session.disconnect();
try {
await mcpServer.session.disconnect();
} catch (error) {
console.error("Error during mcpServer session disconnection:", error);
}

Copilot uses AI. Check for mistakes.

}
});
Expand Down
Loading