-
Notifications
You must be signed in to change notification settings - Fork 579
Skip flaky test on Mono where stderr callbacks are unsupported #980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
src/ModelContextProtocol.Core/Client/StdioClientSessionTransport.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
|
@copilot, this change does not address the issue, as evidenced by CI failing with the problem: Assert.InRange() Failure: Value not in range
Range: (1 - 2147483647)
Actual: 0
at ModelContextProtocol.Tests.Transport.StdioClientTransportTests.CreateAsync_ValidProcessInvalidServer_StdErrCallbackInvoked () [0x001c8] in <69cc817959bb4cc3885cc3ba22a5c8d7>:0
Standard output
| [2025-11-19T13:20:43] ModelContextProtocol.Client.StdioClientTransport Information: stdio-sh connecting.
| [2025-11-19T13:20:43] ModelContextProtocol.Client.StdioClientTransport Information: stdio-sh starting server process. Command: 'sh'.
| [2025-11-19T13:20:43] ModelContextProtocol.Client.StdioClientTransport Information: stdio-sh started server process with PID 8519.
| [2025-11-19T13:20:43] ModelContextProtocol.Client.StdioClientSessionTransport Information: stdio-sh transport reading messages.
| [2025-11-19T13:20:43] ModelContextProtocol.Client.StdioClientSessionTransport Information: stdio-sh transport completed reading messages.
| [2025-11-19T13:20:43] ModelContextProtocol.Client.StdioClientSessionTransport Information: stdio-sh shutting down.
| [2025-11-19T13:20:43] ModelContextProtocol.Client.StdioClientSessionTransport Information: stdio-sh shut down.
| [2025-11-19T13:20:43] ModelContextProtocol.Client.McpClient Error: Client (ModelContextProtocol.Tests 1.0.0.0) client initialization error.
System.IO.IOException: The server shut down unexpectedly.
at System.Threading.Tasks.TaskExtensions.WaitAsync (System.Threading.Tasks.Task task, System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) [0x00265] in <1fc557a7312b4427a8acfe69c788c8e6>:0
at System.Threading.Tasks.TaskExtensions.WaitAsync[T] (System.Threading.Tasks.Task`1[TResult] task, System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) [0x0007f] in <1fc557a7312b4427a8acfe69c788c8e6>:0
at ModelContextProtocol.McpSessionHandler.SendRequestAsync (ModelContextProtocol.Protocol.JsonRpcRequest request, System.Threading.CancellationToken cancellationToken) [0x0038c] in <1fc557a7312b4427a8acfe69c788c8e6>:0
at ModelContextProtocol.McpSession.SendRequestAsync[TParameters,TResult] (System.String method, TParameters parameters, System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[T] parametersTypeInfo, System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[T] resultTypeInfo, ModelContextProtocol.Protocol.RequestId requestId, System.Threading.CancellationToken cancellationToken) [0x000f5] in <1fc557a7312b4427a8acfe69c788c8e6>:0
at ModelContextProtocol.Client.McpClientImpl.ConnectAsync (System.Threading.CancellationToken cancellationToken) [0x001e1] in <1fc557a7312b4427a8acfe69c788c8e6>:0 |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
... You're correct - my previous fix didn't address the issue. In 688a602, I've reverted those changes and implemented the proper fix: skipping the test on Mono where |
Fix flaky test: CreateAsync_ValidProcessInvalidServer_StdErrCallbackInvoked
Summary
Fixed the flaky test by properly skipping it on Mono runtime where
Process.ErrorDataReceivedcallbacks are not reliably supported.Root Cause
The test
CreateAsync_ValidProcessInvalidServer_StdErrCallbackInvokedrelies onProcess.ErrorDataReceivedevent to capture stderr output from a subprocess. This event is not reliably fired on Mono runtime, which is a known platform limitation.The test already had platform detection logic (
IsStdErrCallbackSupported => !PlatformDetection.IsMonoRuntime) to identify this incompatibility, but the skip attribute was commented out, allowing the test to run (and fail) on Mono.The test failed on Mono because:
ErrorDataReceivedevent callback is never invoked on Monocount >= 1)countstill at 0Solution
Uncommented the
[Fact(Skip = ..., SkipUnless = nameof(IsStdErrCallbackSupported))]attribute to properly skip the test on Mono platforms where it cannot succeed.Previous attempts to fix this by modifying
StdioClientSessionTransport.cswith additionalWaitForExit()calls were incorrect and have been reverted, as they did not address the root cause (Mono not firing the event at all).Changes
tests/ModelContextProtocol.Tests/Transport/StdioClientTransportTests.cs: Uncommented the skip attribute to skip test on Monosrc/ModelContextProtocol.Core/Client/StdioClientSessionTransport.cs: Reverted to original code (no changes)Testing & Verification
Security Summary
No security vulnerabilities were introduced or discovered. No code changes to production code.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.