Skip to content

client: suppress duplicate abort errors during StreamableHTTP close#1817

Open
windro-xdd wants to merge 1 commit intomodelcontextprotocol:mainfrom
windro-xdd:fix/streamable-http-close-no-duplicate-onerror
Open

client: suppress duplicate abort errors during StreamableHTTP close#1817
windro-xdd wants to merge 1 commit intomodelcontextprotocol:mainfrom
windro-xdd:fix/streamable-http-close-no-duplicate-onerror

Conversation

@windro-xdd
Copy link
Copy Markdown

Summary

  • add a close-state guard in StreamableHTTPClientTransport to suppress abort-driven onerror emissions while shutdown is in progress
  • keep normal error behavior unchanged when not closing
  • route internal error reporting through a single _emitError helper to avoid duplicate callback paths
  • add regression tests for client.close() abort behavior

Why

Issue #868 reports duplicate onerror callbacks when closing a Streamable HTTP client. During shutdown, in-flight requests can reject with AbortError, and those errors should not be surfaced as user-facing failures after an intentional close.

Validation

  • pnpm --filter @modelcontextprotocol/client test -- test/client/streamableHttp.test.ts
  • pnpm --filter @modelcontextprotocol/client typecheck
  • pnpm --filter @modelcontextprotocol/client lint

Closes #868

@windro-xdd windro-xdd requested a review from a team as a code owner March 29, 2026 15:41
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 29, 2026

⚠️ No Changeset found

Latest commit: d322291

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 Mar 29, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: d322291

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.

When executing client.close(), onerror will be executed twice (Streamable HTTP)

1 participant