Requests to TestHost do not await the `RequestEnd` diagnostic events.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
[I'm writing an OpenTracing instrumentation library](https://github.com/opentracing-contrib/csharp-netcore) that uses the BeginRequest/RequestEnd `DiagnosticSource` events and I'd like to use `TestHost` to write some unit/integration tests.
However, it seems like the HttpClient currently only awaits the response and it doesn't wait until _application.DisposeContext() is called (which then creates the DiagnosticSource events).
https://github.com/aspnet/Hosting/blob/a041b368bb18a00e4c05c6de36928cf0174a6f60/src/Microsoft.AspNetCore.TestHost/HttpContextBuilder.cs#L70-L71
As `TestHost` is for testing the server, it would be great if the client would wait until the request is 100% processed on the server. I currently have to wait/poll a little bit until the underlying task is actually finished.
Would you accept a PR for this?
Contributor guide
Assessment
This issue has not been assessed yet.