fix: stabilize WelcomeServiceStatusProbe RunCommandAsync test#490
Merged
JerrettDavis merged 1 commit intomainfrom Apr 18, 2026
Merged
fix: stabilize WelcomeServiceStatusProbe RunCommandAsync test#490JerrettDavis merged 1 commit intomainfrom
JerrettDavis merged 1 commit intomainfrom
Conversation
…ream-read race WaitForExitAsync does not guarantee that redirected stdout/stderr data has been fully delivered to the async reader tasks before it returns — unlike the synchronous WaitForExit() overload. On Linux CI this causes a race where the process exits, WaitForExitAsync unblocks, and the caller reads empty/partial output before the OS has flushed the pipe buffers. Add a call to the no-arg process.WaitForExit() immediately after WaitForExitAsync completes. This is the pattern documented by Microsoft to ensure all pending stream data is drained before consuming the reader task results, stabilising RunCommandAsync_WhenCommandSucceeds_CapturesExitCodeOutputAndError. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
Code Coverage |
Contributor
Test Results7 641 tests 7 622 ✅ 2m 27s ⏱️ Results for commit 46be263. ♻️ This comment has been updated with latest results. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Process.WaitForExitAsyncdoes not guarantee that redirected stdout/stderr pipe data has been fully delivered to the async reader tasks before it returns. This is a documented .NET behaviour — unlike the synchronousWaitForExit()overload, the async version only waits for the process to exit, not for I/O completion on the redirected streams.WaitForExitAsyncunblocks → code awaitsoutputTask/errorTask→ reads empty/partial strings before the OS has delivered all buffered pipe data. The test then sawOutputnot containing"hello"orErrornot containing"oops".process.WaitForExit()(no-arg synchronous overload) immediately afterWaitForExitAsyncreturns. Microsoft's documentation explicitly states: "To ensure that asynchronous event handling has been completed, call the WaitForExit() overload that takes no parameter after receiving a true return value from this overload." This drains all pending pipe data before the reader tasks are consumed.Test plan
RunCommandAsync_WhenCommandSucceeds_CapturesExitCodeOutputAndError— ran 10 consecutive times locally, 10/10 passedWelcomeServiceStatusProbeExtendedTestsclass — all 31 tests pass, 0 regressions🤖 Generated with Claude Code