Fix flaky ClientStreaming_ResponseCompletesWithoutResponseBody… (#20338)
This commit is contained in:
parent
7d450bba80
commit
f1145fb6d7
|
|
@ -115,10 +115,25 @@ namespace Microsoft.AspNetCore.TestHost
|
|||
// This could throw an error if there was a pending server read. Needs to
|
||||
// happen before completing the response so the response returns the error.
|
||||
var requestBodyInProgress = RequestBodyReadInProgress();
|
||||
if (requestBodyInProgress)
|
||||
{
|
||||
// If request is still in progress then abort it.
|
||||
CancelRequestBody();
|
||||
}
|
||||
|
||||
// Matches Kestrel server: response is completed before request is drained
|
||||
await CompleteResponseAsync();
|
||||
await CompleteRequestAsync(requestBodyInProgress);
|
||||
|
||||
if (!requestBodyInProgress)
|
||||
{
|
||||
// Writer was already completed in send request callback.
|
||||
await _requestPipe.Reader.CompleteAsync();
|
||||
|
||||
// Don't wait for request to drain. It could block indefinitely. In a real server
|
||||
// we would wait for a timeout and then kill the socket.
|
||||
// Potential future improvement: add logging that the request timed out
|
||||
}
|
||||
|
||||
_application.DisposeContext(_testContext, exception: null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -165,24 +180,6 @@ namespace Microsoft.AspNetCore.TestHost
|
|||
CancelRequestBody();
|
||||
}
|
||||
|
||||
private async Task CompleteRequestAsync(bool requestBodyInProgress)
|
||||
{
|
||||
if (requestBodyInProgress)
|
||||
{
|
||||
// If request is still in progress then abort it.
|
||||
CancelRequestBody();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Writer was already completed in send request callback.
|
||||
await _requestPipe.Reader.CompleteAsync();
|
||||
}
|
||||
|
||||
// Don't wait for request to drain. It could block indefinitely. In a real server
|
||||
// we would wait for a timeout and then kill the socket.
|
||||
// Potential future improvement: add logging that the request timed out
|
||||
}
|
||||
|
||||
private bool RequestBodyReadInProgress()
|
||||
{
|
||||
try
|
||||
|
|
|
|||
Loading…
Reference in New Issue