Skip to content

fix(client): surface underlying network error via Error.cause on probe failures (#2657) - #2726

Open
LuckTerence wants to merge 5 commits into
modelcontextprotocol:mainfrom
LuckTerence:fix/sdk-error-cause-chain
Open

fix(client): surface underlying network error via Error.cause on probe failures (#2657)#2726
LuckTerence wants to merge 5 commits into
modelcontextprotocol:mainfrom
LuckTerence:fix/sdk-error-cause-chain

Conversation

@LuckTerence

Copy link
Copy Markdown

Closes #2657

Bug

classifyNetworkError passed { cause: error } as the third constructor argument of SdkError — the data slot. The underlying TypeError: fetch failed (and the DNS error beneath it) therefore never reached the standard Error.cause chain: anything walking .cause stops at the SdkError with cause === undefined.

Changes

  • packages/core-internal/src/errors/sdkErrors.ts: SdkError now accepts an optional ErrorOptions fourth argument and forwards it to super (standard ES error-causing; backward compatible — data stays the third parameter and SdkHttpError is untouched)
  • packages/client/src/client/probeClassifier.ts: classifyNetworkError now passes the underlying error via { cause } options instead of the data slot
  • Regression test in probeClassifier.test.ts: asserts the verdict's error.cause is the original network error

Verification

  • packages/client: vitest run test/client/probeClassifier.test.ts → 36/36 passed
  • packages/core-internal: full suite → 69 files / 1447 tests passed
  • Repo pre-push hooks (Build / Typecheck / Lint) all green

@LuckTerence
LuckTerence requested a review from a team as a code owner August 26, 2026 18:00
@changeset-bot

changeset-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8107d7c

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/core-internal Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/codemod 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

pkg-pr-new Bot commented Aug 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2726

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2726

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2726

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 8107d7c

LuckTerence and others added 4 commits August 27, 2026 14:19
The probeAuthSeam control test reads the underlying network error via
SdkError.data.cause; passing it only as ErrorOptions left data undefined
and crashed the suite. Populate both slots so the legacy data.cause
contract and the standard Error.cause chain (modelcontextprotocol#2657) both hold.
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.

[v2] classifyNetworkError passes { cause } into SdkError's data slot, so the underlying network error never reaches Error.cause

1 participant