Skip to content

Commit 58937db

Browse files
authored
Merge branch 'main' into copilot/fix-flaky-tests-ci
2 parents 1842f77 + 1dd06e7 commit 58937db

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/ModelContextProtocol.Core/Client/StdioClientTransport.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ internal static void DisposeProcess(
227227
// and Node.js does not kill its children when it exits properly.
228228
process.KillTree(shutdownTimeout);
229229
}
230+
231+
// Ensure all redirected stderr/stdout events have been dispatched
232+
// before disposing. Only the no-arg WaitForExit() guarantees this;
233+
// WaitForExit(int) (as used by KillTree) does not.
234+
// This should not hang: either the process already exited on its own
235+
// (no child processes holding handles), or KillTree killed the entire
236+
// process tree. If it does take too long, the test infrastructure's
237+
// own timeout will catch it.
238+
if (!processRunning && HasExited(process))
239+
{
240+
process.WaitForExit();
241+
}
230242
}
231243
finally
232244
{

0 commit comments

Comments
 (0)