Skip to content

Allow streamable HTTP transport restart after close#2174

Open
FU-max-boop wants to merge 1 commit into
modelcontextprotocol:mainfrom
FU-max-boop:fix/streamable-http-restart-after-close
Open

Allow streamable HTTP transport restart after close#2174
FU-max-boop wants to merge 1 commit into
modelcontextprotocol:mainfrom
FU-max-boop:fix/streamable-http-restart-after-close

Conversation

@FU-max-boop
Copy link
Copy Markdown

Summary

Fixes #1641.

StreamableHTTPClientTransport.close() aborted the current controller but kept the aborted controller object around. A later start() therefore treated the transport as already started, which breaks reconnect flows that close the transport during OAuth and then start it again after authorization.

This clears the controller after aborting it, and updates the delayed reconnect guard so late scheduler callbacks also stop when the transport has been closed and the controller has been cleared.

Tests

  • corepack pnpm --filter @modelcontextprotocol/client exec vitest run test/client/streamableHttp.test.ts
  • corepack pnpm --filter @modelcontextprotocol/client lint
  • corepack pnpm --filter @modelcontextprotocol/client typecheck
  • git diff --check

Note: the first attempt to run the package test via corepack pnpm --filter @modelcontextprotocol/client test -- streamableHttp.test.ts executed the broader client suite and only failed because barrelClean.test.ts spawns pnpm by name, while this environment only exposes pnpm through Corepack. The targeted pnpm exec vitest run above passed.

@FU-max-boop FU-max-boop requested a review from a team as a code owner May 29, 2026 01:53
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 29, 2026

🦋 Changeset detected

Latest commit: d2bf224

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/client Patch

Not sure what this means? Click here to learn what changesets are.

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 29, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@2174

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/codemod@2174

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@2174

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@2174

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/fastify@2174

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@2174

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@2174

commit: d2bf224

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.

StreamableHTTPClientTransport cannot be restarted after close() — breaks OAuth re-authentication

1 participant