Skip to content

fix: stabilize WelcomeServiceStatusProbe RunCommandAsync test#490

Merged
JerrettDavis merged 1 commit intomainfrom
fix/welcome-probe-runcommand-flake
Apr 18, 2026
Merged

fix: stabilize WelcomeServiceStatusProbe RunCommandAsync test#490
JerrettDavis merged 1 commit intomainfrom
fix/welcome-probe-runcommand-flake

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Summary

  • Root cause: Process.WaitForExitAsync does 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 synchronous WaitForExit() overload, the async version only waits for the process to exit, not for I/O completion on the redirected streams.
  • The race: On Linux CI runners (which are more resource-constrained and schedule OS pipe flushes later), the sequence was: process exits → WaitForExitAsync unblocks → code awaits outputTask/errorTask → reads empty/partial strings before the OS has delivered all buffered pipe data. The test then saw Output not containing "hello" or Error not containing "oops".
  • The fix: Add process.WaitForExit() (no-arg synchronous overload) immediately after WaitForExitAsync returns. 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

Note: The flake does not reproduce locally on Windows (Windows pipe flushing semantics differ), but the hazard is real and the fix is correct per the .NET Process documentation. The fix is purely additive — WaitForExit() after WaitForExitAsync is a no-op when the process has already exited and streams are already drained.

🤖 Generated with Claude Code

…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>
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 04/18/2026 - 15:44:43
  Coverage date: 04/18/2026 - 15:42:50 - 04/18/2026 - 15:44:34
  Parser: MultiReport (7x Cobertura)
  Assemblies: 23
  Classes: 1067
  Files: 591
  Line coverage: 74.6%
  Covered lines: 36826
  Uncovered lines: 12486
  Coverable lines: 49312
  Total lines: 97268
  Branch coverage: 63.6% (14339 of 22512)
  Covered branches: 14339
  Total branches: 22512
  Method coverage: 86.4% (6317 of 7308)
  Full method coverage: 74.2% (5426 of 7308)
  Covered methods: 6317
  Fully covered methods: 5426
  Total methods: 7308

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 18, 2026

Test Results

7 641 tests   7 622 ✅  2m 27s ⏱️
    7 suites     19 💤
    7 files        0 ❌

Results for commit 46be263.

♻️ This comment has been updated with latest results.

@JerrettDavis JerrettDavis added the coverage-override Bypass coverage gate check label Apr 18, 2026
@JerrettDavis JerrettDavis merged commit ed59101 into main Apr 18, 2026
15 of 16 checks passed
@JerrettDavis JerrettDavis deleted the fix/welcome-probe-runcommand-flake branch April 18, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coverage-override Bypass coverage gate check size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant