Skip to content

fix(server): surface parse/validation transport errors via onerror in streamable HTTP#1684

Open
Maverick-666 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Maverick-666:codex/fix-transport-onerror
Open

fix(server): surface parse/validation transport errors via onerror in streamable HTTP#1684
Maverick-666 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Maverick-666:codex/fix-transport-onerror

Conversation

@Maverick-666
Copy link

Summary

This PR fixes missing onerror propagation in StreamableHTTPServerTransport when request parsing/validation fails.

What changed

  • Updated packages/server/src/server/streamableHttp.ts:
    • call this.onerror?.(...) when req.json() fails
    • call this.onerror?.(...) when JSONRPCMessageSchema.parse(...) fails
  • Added regression tests in packages/server/test/server/streamableHttp.test.ts to verify both paths trigger onerror

Why

Previously, these transport-level errors could be handled in HTTP responses but were not reported through onerror, making observability and custom error handling inconsistent.

Validation

  • pnpm --filter @modelcontextprotocol/server test -- test/server/streamableHttp.test.ts
  • Targeted lint/format checks for modified files

Closes #1395

@Maverick-666 Maverick-666 requested a review from a team as a code owner March 16, 2026 02:33
@changeset-bot
Copy link

changeset-bot bot commented Mar 16, 2026

⚠️ No Changeset found

Latest commit: 02634bf

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

pkg-pr-new bot commented Mar 16, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 02634bf

@Maverick-666
Copy link
Author

Quick follow-up: all required project CI checks are passing, and this PR is ready for code-owner review.

One external review check (Claude Code Review) appears to be stuck in progress for over an hour. Could a maintainer please take a look when convenient?

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.

Some transport errors are silently swallowed due to missing onerror callback usage

1 participant