Skip to content

Conversation

@d-markey
Copy link

Hello,

I experienced an issue when using a MCP server (using dart_mcp which uses this package). Worked well on VM, but when I switched to Web, MCP initialization never returned. As it turns out, the target MCP server does not support CORS (eg. https://api.githubcopilot.com/mcp/) and it seems the error never flows back to the code that initializes the MCP server, so the corresponding future never completes. This is tracked in issue #2202.

I've added a test "can send a message and receive an error" that mimics the behavior I observed: the test times out without this fix. The fix consists in forwarding the error to both the client and the server. As it turns out, the Peer never called _clientIncomingForwarder.addError() which seems odd?

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.

I experienced an issue when using a MCP server (using `dart_mcp` which uses this package). Worked well on VM, but when I switched to Web, MCP initialization never returned. As it turns out, the target MCP server does not support CORS (eg. https://api.githubcopilot.com/mcp/) and it seems the error never flows back to the code that initializes the MCP server, so the corresponding future never completes.

I've added a test "can send a message and receive an error" that mimics the behavior I observed: the test times out without this fix. The fix consists in forwarding the error to both the client and the server.
@d-markey d-markey requested a review from a team as a code owner October 26, 2025 17:48
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses an issue where pending requests on a Peer would hang indefinitely if the underlying communication channel produced an error. The fix correctly propagates the channel error to both the client and server components of the Peer, ensuring that pending client requests are properly terminated. The introduction of a new test case successfully validates this fix by simulating a channel error and asserting the expected failure of a pending request. Additionally, enabling web platform testing is a valuable improvement. The code changes, including some nice formatting improvements, are clean, well-tested, and follow Dart best practices.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant