Close stdio input before waiting for server exit - #1838
Conversation
b01139d to
620d49c
Compare
|
The current Windows Debug failure is unrelated to the stdio transport change. The two failed tests were:
The changed StdioClientTransportTests had no failures. Windows Release and both configurations on Ubuntu and macOS passed, and the focused stdio suite passes 216/216 locally. GitHub did not permit me to rerun the failed job from the fork, so a maintainer rerun may be needed. |
halter73
left a comment
There was a problem hiding this comment.
Thanks for tracking this down, filing such a thorough issue, and following through with a focused fix and regression test. I left one small comment about logging the failed close path, but otherwise this looks great.
| { | ||
| _process.StandardInput.Close(); | ||
| } | ||
| catch { } |
There was a problem hiding this comment.
Can we log in the unlikely event this catches anything? I was tempted to suggest removing the catch since closing stdin should succeed even after the process exits, but preserving the fallback kill seems safer. A warning like "{EndpointName} failed to close server standard input; continuing shutdown." would work.
Summary
ShutdownTimeoutValidation
dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj --filter FullyQualifiedName~StdioClientTransportTests— 54 passed on each of net472, net8.0, net9.0, and net10.0 (216 total)dotnet build -c Release— succeeded with 0 warnings and 0 errorsShutdownTimeoutand pass with this change by observing a clean exit code of 0, without asserting wall-clock durationThe full test suite was also attempted locally. Unrelated environment dependencies involving the missing Node conformance helper and a localhost OAuth development certificate prevented a clean full-suite completion. One parallel task-cancellation test also failed during that run and passed when rerun in isolation.
Fixes #1836
Note
This pull request description and implementation were prepared with AI assistance.