Skip to content

fix:close transport on connection failure#1862

Open
sid293 wants to merge 2 commits intomodelcontextprotocol:mainfrom
sid293:fix/close-transport-on-connection-failure
Open

fix:close transport on connection failure#1862
sid293 wants to merge 2 commits intomodelcontextprotocol:mainfrom
sid293:fix/close-transport-on-connection-failure

Conversation

@sid293
Copy link
Copy Markdown

@sid293 sid293 commented Apr 8, 2026

Fixes a resource leak on connection failure and resolves TypeScript error in packages/client/test/client/auth.test.ts.

Motivation and Context

client.ts: Moved super.connect() inside the try block so the catch block can properly close the transport if initialization fails.

auth.test.ts: Added as unknown as RequestInit to resolve a type mismatch on the optional cache property.

How Has This Been Tested?

Added a new integration test to verify that the transport is closed even when startup fails.
All tests were verified passing using the workspace-wide command: pnpm test:all

Breaking Changes

none

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@sid293 sid293 requested a review from a team as a code owner April 8, 2026 16:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

⚠️ No Changeset found

Latest commit: 28792b5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 8, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@1862

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@1862

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@1862

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@1862

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@1862

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@1862

commit: 28792b5

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.

1 participant