Cancel Kestrel write loops on disconnect/reset
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
https://github.com/dotnet/aspnetcore/blob/4092201629a7feea1ead23202aff4ee8f5b77664/src/Servers/Kestrel/Core/src/Internal/Http2/Http2OutputProducer.cs#L456-L460
https://github.com/dotnet/aspnetcore/blob/a67c217976899db93563353daa6276e438fe677b/src/Servers/Kestrel/Core/src/Internal/Http3/Http3OutputProducer.cs#L372-L376
Kestrel uses a pipe for the response body and a pipe for the connection and runs a copy loop in between. Right now it doesn't check the flushresult and will keep copying even if the client has disconnected or reset the stream.
Proposal: Cancel the ProcessDataWrites loop and complete the response body pipe reader early if the client disconnects or otherwise resets the stream. That will allow application components to check the pipe flush results and also terminate early when the reader is completed.
Contributor guide
Assessment
This issue has not been assessed yet.