Skip to content

fix(sdk): forward hasPerRequestStream so modern cancellation aborts t… - #4474

Open
ignaciojimenezr wants to merge 1 commit into
MCPJam:mainfrom
ignaciojimenezr:fix/modern-cancellation-per-request-stream
Open

fix(sdk): forward hasPerRequestStream so modern cancellation aborts t…#4474
ignaciojimenezr wants to merge 1 commit into
MCPJam:mainfrom
ignaciojimenezr:fix/modern-cancellation-per-request-stream

Conversation

@ignaciojimenezr

@ignaciojimenezr ignaciojimenezr commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

…he stream

MCP 2026-07-28 makes closing the per-request stream the cancellation signal on Streamable HTTP, and says no notifications/cancelled is expected. The client package forks on era === modern && transport.hasPerRequestStream === true, but every transport we pass to a client is wrapped, and the wrappers forwarded sessionId and setProtocolVersion while dropping hasPerRequestStream.

The flag read undefined, so the fork took the legacy branch on every connection — including plain ones, since wrapTransportForTaskResults is applied unconditionally at each HTTP transport site. We POSTed a notification modern servers do not expect, and because that notification is a separate request from the call being cancelled, the server ran the tool to completion having never seen the one signal that would have reached it.

Forward the flag from all five wrappers (four in transport-utils, one in the widget runtime). Forwarded, not defaulted: over stdio the notification is still the correct signal.

The existing modern-abort test passed the whole time because the legacy branch POSTs fire-and-forget and the assertion ran before it landed. Let that settle, and also assert the aborted tools/call exchange actually terminates.


Summary by cubic

Fixes modern MCP cancellation by forwarding hasPerRequestStream through all transport wrappers, so the protocol layer aborts the per-request stream instead of POSTing notifications/cancelled. Previously the flag was dropped, so every connection took the legacy branch, sending a signal modern servers neither expect nor receive.

  • Forwards the getter from the four wrappers in transport-utils and the widget runtime's LoggingTransport.
  • Forwards, never defaults, so stdio transports still use the notification signal.
  • Strengthens the integration test to wait out the legacy fire-and-forget POST and assert the aborted tools/call exchange actually terminates.

Written for commit 246472d. Summary will update on new commits.

Review in cubic

…he stream

MCP 2026-07-28 makes closing the per-request stream the cancellation signal on
Streamable HTTP, and says no notifications/cancelled is expected. The client
package forks on `era === modern && transport.hasPerRequestStream === true`,
but every transport we pass to a client is wrapped, and the wrappers forwarded
sessionId and setProtocolVersion while dropping hasPerRequestStream.

The flag read undefined, so the fork took the legacy branch on every
connection — including plain ones, since wrapTransportForTaskResults is applied
unconditionally at each HTTP transport site. We POSTed a notification modern
servers do not expect, and because that notification is a separate request from
the call being cancelled, the server ran the tool to completion having never
seen the one signal that would have reached it.

Forward the flag from all five wrappers (four in transport-utils, one in the
widget runtime). Forwarded, not defaulted: over stdio the notification is still
the correct signal.

The existing modern-abort test passed the whole time because the legacy branch
POSTs fire-and-forget and the assertion ran before it landed. Let that settle,
and also assert the aborted tools/call exchange actually terminates.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Aug 29, 2026
@chelojimenez

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 72b8aa84-7488-4d4d-9182-e73744088703

📥 Commits

Reviewing files that changed from the base of the PR and between 74de847 and 246472d.

📒 Files selected for processing (4)
  • .changeset/modern-cancellation-aborts-the-stream.md
  • sdk/src/mcp-client-manager/transport-utils.ts
  • sdk/src/widget-runtime/logging-transport.ts
  • sdk/tests/modern-evidence.integration.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


Walkthrough

Transport wrappers now forward hasPerRequestStream from their inner transports, including manager and widget-runtime logging wrappers. The protocol layer can therefore distinguish modern per-request stream cancellation from legacy notification cancellation. The integration test waits for fire-and-forget cancellation delivery, confirms that no legacy notification is sent for the modern path, and verifies that the aborted tools/call exchange terminates. A changeset documents the behavior.

Merge Risk: ⚪ Minimal · up to 24647

This change makes modern HTTP cancellation terminate the active request stream while preserving legacy behavior for transports without per-request streams. No actionable merge-blocking risk remains beyond normal checks and review.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants