RequestBodyCanceled is ambiguous (client- vs. destination-initiated?)
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 933
- Avg merge
- 12d 18h
- Merged PRs (30d)
- 2
Description
### Describe the bug
YARP result `ForwarderError.RequestBodyCanceled` is ambiguous in .NET 5+ since the introduction of overload `StreamCopyHttpContent.SerializeToStreamAsync(Stream, TransportContext, CancellationToken)`.
In the past, `RequestBodyCanceled` meant precisely that the client canceled early (i.e. `HttpContext.Aborted` was signaled).
But since .NET 5 and up, it can also mean that the destination canceled early. YARP does not allow disambiguation between the two (though arguably we could still figure it out by manually checking `HttpContext.Aborted.IsCancellationRequested`).
This issue is benign and YARP is doing the right thing functionally. This issue is primarily for awareness in case others run into the same issue, but also to have the discussion whether it is worth being more specific and explicit about which side canceled (client vs. destination).
### To Reproduce
Use YARP to establish an HTTP/2 gRPC duplex channel to a destination, and have the destination initiate a graceful shutdown of the session.
### Further technical details
Relevant code snippet in YARP:
https://github.com/microsoft/reverse-proxy/blob/7ca6acb0594489cb8bedce12662f0c7f58d797a5/src/ReverseProxy/Forwarder/StreamCopyHttpContent.cs#L137-L154
- `YARP.ReverseProxy 1.0.0`
- `.NET 6.0.2`
Contributor guide
Research direction
Start with StreamCopyHttpContent.cs at the linked lines 137-154 and reproduce the HTTP/2 gRPC duplex scenario where the destination gracefully shuts down. Compare that behavior with client cancellation through HttpContext.Aborted. Done means reaching a documented decision on whether cancellation sources should be distinguished and what change, if any, is required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100