Skip to content

fix: handle cancellation for request ID 0 - #2654

Open
pshah19 wants to merge 1 commit into
modelcontextprotocol:mainfrom
pshah19:fix/cancellation-request-id-zero
Open

fix: handle cancellation for request ID 0#2654
pshah19 wants to merge 1 commit into
modelcontextprotocol:mainfrom
pshah19:fix/cancellation-request-id-zero

Conversation

@pshah19

@pshah19 pshah19 commented Aug 12, 2026

Copy link
Copy Markdown

Summary

  • Handle requestId: 0 as a valid JSON-RPC request ID in cancellation notifications
  • Add regression coverage confirming that request handlers with ID 0 are aborted correctly

Root cause

The cancellation handler used a truthiness check for requestId, causing the valid numeric ID 0 to be treated as missing.

Testing

  • pnpm --filter @modelcontextprotocol/core-internal exec vitest run test/shared/protocol.test.ts
  • pnpm --filter @modelcontextprotocol/core-internal check
  • pnpm lint:all
  • pnpm test:all — 1 transient SSE timeout; the failed E2E scenario passed when rerun independently

Fixes #2283

@pshah19
pshah19 requested a review from a team as a code owner August 12, 2026 17:34
@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c2f4d2d

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

pkg-pr-new Bot commented Aug 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

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

@modelcontextprotocol/core

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

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: c2f4d2d

@KKonstantinov KKonstantinov self-assigned this Aug 13, 2026
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.

notifications/cancelled is ignored for request id 0

2 participants