Skip to content

Commit

Permalink
diagnose: don't await Git exit on config list
Browse files Browse the repository at this point in the history
Do not wait for the Git process to exit, before reading from the stdout
stream, to prevent a deadlock. This is what we do in the product code
too.
  • Loading branch information
mjcheetham committed Jul 25, 2022
1 parent 10935fb commit 1d54224
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/shared/Core/Diagnostics/GitDiagnostic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ protected override Task<bool> RunInternalAsync(StringBuilder log, IList<string>
log.Append("Listing all Git configuration...");
Process configProc = _git.CreateProcess("config --list --show-origin");
configProc.Start();
configProc.WaitForExit();
// To avoid deadlocks, always read the output stream first and then wait
// TODO: don't read in all the data at once; stream it
string gitConfig = configProc.StandardOutput.ReadToEnd().TrimEnd();
configProc.WaitForExit();
log.AppendLine(" OK");
log.AppendLine("Git configuration:");
log.AppendLine(gitConfig);
Expand Down

0 comments on commit 1d54224

Please sign in to comment.