Skip to content

Conversation

halter73
Copy link
Contributor

@halter73 halter73 commented Apr 9, 2025

  • Previously the ChannelWriter could already be completed if multiple threads raced in SetConnected(false)
  Failed ModelContextProtocol.Tests.ClientIntegrationTests.CallTool_Stdio_EchoServer(clientId: "test_server") [331 ms]
  Error Message:
   System.Threading.Channels.ChannelClosedException : The channel has been closed.
  Stack Trace:
     at System.Threading.Channels.ChannelWriter`1.Complete(Exception error)
   at ModelContextProtocol.Protocol.Transport.TransportBase.SetConnected(Boolean isConnected) in /_/src/ModelContextProtocol/Protocol/Transport/TransportBase.cs:line 75
   at ModelContextProtocol.Protocol.Transport.StreamClientSessionTransport.CleanupAsync(CancellationToken cancellationToken) in /_/src/ModelContextProtocol/Protocol/Transport/StreamClientSessionTransport.cs:line 192
   at ModelContextProtocol.Client.McpClient.DisposeUnsynchronizedAsync() in /_/src/ModelContextProtocol/Client/McpClient.cs:line 184
   at ModelContextProtocol.Shared.McpEndpoint.DisposeAsync() in /_/src/ModelContextProtocol/Shared/McpEndpoint.cs:line 89
   at ModelContextProtocol.Tests.ClientIntegrationTests.CallTool_Stdio_EchoServer(String clientId) in /_/tests/ModelContextProtocol.Tests/ClientIntegrationTests.cs:line 95
--- End of stack trace from previous location ---
  Standard Output Messages:
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClientFactory Information: Creating client for TestServer
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Sending request for TestServer with method initialize
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Request response received payload for TestServer: {"protocolVersion":"2024-11-05","capabilities":{"logging":{},"prompts":{},"resources":{"subscribe":true},"tools":{},"completions":{}},"serverInfo":{"name":"TestServer","version":"1.0.0.0"},"instructions":"This is a test server with only stub functionality"}
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Request response received for TestServer with method initialize
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Server TestServer capabilities received: {"logging":{},"prompts":{},"resources":{"subscribe":true},"tools":{},"completions":{}}, server info: {"name":"TestServer","version":"1.0.0.0"}
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClientFactory Information: Client for TestServer created and connected
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Sending request for TestServer with method tools/call
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Request response received payload for TestServer: {"content":[{"type":"text","text":"Echo: Hello MCP!"}],"isError":false}
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Request response received for TestServer with method tools/call
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Cleaning up endpoint TestServer
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Endpoint message processing cancelled for TestServer
 | [2025-04-09T16:35:33] ModelContextProtocol.Client.McpClient Information: Endpoint cleaned up for TestServer

https://github.com/modelcontextprotocol/csharp-sdk/actions/runs/14362374601/job/40266898759?pr=252

- Previously the ChannelWriter could already be completed if multiple
  threads raced in SetConnected(false)
@eiriktsarpalis eiriktsarpalis merged commit 08f9cdb into modelcontextprotocol:main Apr 9, 2025
8 checks passed
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.

2 participants