Skip to content

Fix falsy-zero requestId bugs in cancel and debounce paths#2529

Open
kharerajat2014 wants to merge 1 commit into
modelcontextprotocol:mainfrom
kharerajat2014:fix/2283-2117-falsy-zero-request-id
Open

Fix falsy-zero requestId bugs in cancel and debounce paths#2529
kharerajat2014 wants to merge 1 commit into
modelcontextprotocol:mainfrom
kharerajat2014:fix/2283-2117-falsy-zero-request-id

Conversation

@kharerajat2014

@kharerajat2014 kharerajat2014 commented Jul 21, 2026

Copy link
Copy Markdown

Summary

  • _oncancel: stop dropping notifications/cancelled when requestId === 0 (legal JSON-RPC id; also the first id Protocol assigns via _requestMessageId = 0)
  • Debounce guard: stop treating relatedRequestId: 0 as absent so related notifications are not incorrectly coalesced
  • Regression tests in packages/core-internal/test/shared/protocol.test.ts + patch changeset for @modelcontextprotocol/core-internal

Fixes #2283
Fixes #2117
(Also related: #2115)

Note on overlapping PRs

#2504 and several other open PRs address the same root cause. Happy to close this in favor of whichever PR maintainers prefer, or adjust to a v1.x backport / e2e follow-up if that is more useful.

Test plan

  • New tests fail on pre-fix code (TDD red)
  • pnpm --filter @modelcontextprotocol/core-internal exec vitest run test/shared/protocol.test.ts — 41 passed
  • Pre-push hook: build + lint + typecheck (lefthook)

JSON-RPC id 0 is legal and is the first id Protocol assigns; truthiness
guards were dropping cancels and incorrectly debounce-coalescing related
notifications. Add regression tests and a patch changeset.

Fixes modelcontextprotocol#2283
Fixes modelcontextprotocol#2117

Co-authored-by: Cursor <cursoragent@cursor.com>
@kharerajat2014
kharerajat2014 requested a review from a team as a code owner July 21, 2026 12:49
@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: af77aba

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

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/core-internal 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 Jul 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

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

@modelcontextprotocol/core

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

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: af77aba

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 relatedRequestId 0 is treated as absent by notification debounce guard

1 participant