Skip to content

Commit 2c41608

Browse files
ericstjCopilot
andcommitted
Suppress EC flow in BeginErrorReadLine and fix diagnostic log glob
- Add ExecutionContext.SuppressFlow() around process.BeginErrorReadLine() to prevent the Process's internal async stderr reader from capturing the caller's execution context. This avoids potential interference between the background reader thread and the caller's async tracking (e.g., xUnit test runner state), which was correlated with intermittent test host hangs on .NET 9+. - Fix CI artifact upload glob: change artifacts/bin/*Tests/*/xunit-runtest-diag.log to **/xunit-runtest-diag.log so the instrumented xUnit diagnostic log is actually captured when the test host hangs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 567b4f9 commit 2c41608

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

.github/workflows/ci-build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
name: testresults-${{ matrix.os }}-${{ matrix.configuration }}
8787
path: |
8888
artifacts/testresults/**
89-
artifacts/bin/*Tests/*/xunit-runtest-diag.log
89+
**/xunit-runtest-diag.log
9090
9191
publish-coverage:
9292
if: github.actor != 'dependabot[bot]'

src/ModelContextProtocol.Core/Client/StdioClientTransport.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ public async Task<ITransport> ConnectAsync(CancellationToken cancellationToken =
203203

204204
LogTransportProcessStarted(logger, endpointName, process.Id);
205205

206-
process.BeginErrorReadLine();
206+
// Suppress ExecutionContext flow so the Process's internal async
207+
// stderr reader thread doesn't capture the caller's context.
208+
using (ExecutionContext.SuppressFlow())
209+
{
210+
process.BeginErrorReadLine();
211+
}
207212

208213
return new StdioClientSessionTransport(_options, process, endpointName, stderrRollingLog, errorHandler, _loggerFactory);
209214
}

0 commit comments

Comments
 (0)