Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -832,12 +832,17 @@ private async Task BuildSampleAsync(string samplePath)

using Process buildProcess = new() { StartInfo = buildInfo };
buildProcess.Start();

// Read both streams asynchronously to avoid deadlocks from filled pipe buffers
Task<string> stdoutTask = buildProcess.StandardOutput.ReadToEndAsync();
Task<string> stderrTask = buildProcess.StandardError.ReadToEndAsync();
await buildProcess.WaitForExitAsync();

Comment on lines +836 to 840
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdoutTask is started but never awaited on the success path. Since buildProcess is disposed at the end of the method, the outstanding read can fault and produce unobserved task exceptions or flaky behavior. Suggest awaiting both stdoutTask and stderrTask unconditionally (e.g., await Task.WhenAll(...)) before exiting the method.

Copilot uses AI. Check for mistakes.
string stderr = await stderrTask;
if (buildProcess.ExitCode != 0)
{
string stderr = await buildProcess.StandardError.ReadToEndAsync();
throw new InvalidOperationException($"Failed to build sample at {samplePath}: {stderr}");
string stdout = await stdoutTask;
throw new InvalidOperationException($"Failed to build sample at {samplePath}:\n{stdout}\n{stderr}");
}

this._outputHelper.WriteLine($"Build completed for {samplePath}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,12 +830,17 @@ private async Task BuildSampleAsync(string samplePath)

using Process buildProcess = new() { StartInfo = buildInfo };
buildProcess.Start();

// Read both streams asynchronously to avoid deadlocks from filled pipe buffers
Task<string> stdoutTask = buildProcess.StandardOutput.ReadToEndAsync();
Task<string> stderrTask = buildProcess.StandardError.ReadToEndAsync();
await buildProcess.WaitForExitAsync();

Comment on lines +834 to 838
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdoutTask is started but only awaited on the failure path. On a successful build this method can return (and dispose buildProcess) while stdoutTask is still reading, which can lead to unobserved task exceptions / ObjectDisposedException and flaky runs. Consider awaiting both reads unconditionally (e.g., await Task.WhenAll(stdoutTask, stderrTask) before checking ExitCode, or at least await stdoutTask on success).

Copilot uses AI. Check for mistakes.
string stderr = await stderrTask;
if (buildProcess.ExitCode != 0)
{
string stderr = await buildProcess.StandardError.ReadToEndAsync();
throw new InvalidOperationException($"Failed to build sample at {samplePath}: {stderr}");
string stdout = await stdoutTask;
throw new InvalidOperationException($"Failed to build sample at {samplePath}:\n{stdout}\n{stderr}");
}

this._outputHelper.WriteLine($"Build completed for {samplePath}.");
Expand Down
Loading