Investigate the race condition in Praefect that error messages are not fully flushed
In some CI job failures, 4014261243 and 2207724348 for example, we discover a race condition in Praefect. When the upload-pack command returns an error in stderr, a gRPC error is returned and the content of stderr is copied back to the client. Without Praefect, everything is fine. However, when Praefect is enabled, the content of stderr is not flushed before downstream receives the error. As a result, the client sometimes receives an empty response.
We are not sure if this racing error is specific to PostUploadPackWithSidechannel or if it's a common bug to all RPCs using Sidechannel.