-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(RevisionReader): Avoid hang on lengthy StandardOutput #12072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(RevisionReader): Avoid hang on lengthy StandardOutput #12072
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 looks reasonable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -184,13 +201,21 @@ public IReadOnlyCollection<GitRevision> GetRevisionsFromRange(string olderCommit | |||
Debug.WriteLine($"git {arguments}"); | |||
#endif | |||
using IProcess process = _module.GitCommandRunner.RunDetached(cancellationToken, arguments, redirectOutput: true, outputEncoding: null); | |||
string errorOutput = process.StandardError.ReadToEnd(); | |||
|
|||
// StandardError.ReadToEnd[Async] hangs if lengthy StandardOutput is not consumed in parallel. So, buffer the StandardOutput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// StandardError.ReadToEnd[Async] hangs if lengthy StandardOutput is not consumed in parallel. So, buffer the StandardOutput | |
// StandardError.ReadToEnd[Async] may become unresponsive, if lengthy StandardOutput is not consumed in parallel. So, buffer the StandardOutput. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
string errorOutput = process.StandardError.ReadToEnd(); | ||
|
||
// StandardError.ReadToEnd[Async] hangs if lengthy StandardOutput is not consumed in parallel. So, buffer the StandardOutput | ||
MemoryStream standardOutputBuffer = new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MemoryStream standardOutputBuffer = new(); | |
using MemoryStream standardOutputBuffer = new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
36127ec
to
126043a
Compare
126043a
to
51dd817
Compare
Fixes #12055
Proposed changes
RevisionReader.GetRevision
): Avoid hang inStandardError.ReadToEnd
on lengthyStandardOutput
GitCommandRunner.RunDetached
are not affected as they do not readStandardError
at all.GetRevisionAsync
as proposed by Roslyn analyzerScreenshots
N/A
Test methodology
Test environment(s)
https://github.com/mstv/test_lfs/tree/test_long_commit_body
Merge strategy
I agree that the maintainer squash merge this PR (if the commit message is clear).
✒️ I contribute this code under The Developer Certificate of Origin.