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

Conversation

nirinchev
Copy link
Collaborator

Proposed changes

Checklist

@Copilot Copilot AI review requested due to automatic review settings July 11, 2025 11:54
@nirinchev nirinchev requested a review from a team as a code owner July 11, 2025 11:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modifies the test cleanup logic to always disconnect the session after each test run, removing a conditional check that previously only disconnected when no Atlas cluster was connected.

  • Simplified the session disconnect logic in the afterEach hook to always disconnect when an MCP server exists
  • Removed the conditional check for connectedAtlasCluster status before disconnection

@@ -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.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 16219386259

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.06%) to 75.27%

Files with Coverage Reduction New Missed Lines %
src/session.ts 2 77.5%
Totals Coverage Status
Change from base Build 16217682500: -0.06%
Covered Lines: 886
Relevant Lines: 1087

💛 - Coveralls

@fmenezes fmenezes changed the title chore: always disconnect the session after a test run fix: always disconnect the session after a test run Jul 11, 2025
@nirinchev nirinchev merged commit b10990b into main Jul 11, 2025
19 checks passed
@nirinchev nirinchev deleted the ni/tests branch July 11, 2025 12:13
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.

3 participants