Proper way to be notified about stream failure
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 836
- Avg merge
- 6d 3h
- Merged PRs (30d)
- 7
Description
Hi,
Recently I've run into the following situation:
* consumer connects to stream
* starts receiving data via `ResponseStream.MoveNext()`
* consumer is too slow to process the data, he gets disconnected with `RpcException(Aborted, "You're too slow")`
* consumer finishes processing last bit of data that's available to him, uses `RequestStream.WriteAsync()` to write an ack, receives `RpcException(Cancelled, "")` (due to underlying HttpClient being disconnected I presume?)
At this stage, if consumer were to interact with `ResponseStream`, he'd actually receive the correct Exception.
Is this intended? Could those exceptions be synced up somehow? And most importantly - was the question clear enough or should I write a repro? :D
For visual clue, I suppose best representation would be:
```
while (await responseStream.MoveNext())
{
var message = responseStream.Current;
ProcessMessage(message); // <--- Takes too long, consumer is disconnected after this line
await requestStream.WriteAsync(message); // <--- this will fail, but it will fail with a different exception than what I'd expect. Tho I understand why it has to be this way.
}
```
It feels like even knowing that `requestStream` is dead, you're supposed to finish reading `MoveNext()` to get the real reason.
Contributor guide
Research direction
Start by reproducing the bidirectional streaming sequence using ResponseStream.MoveNext() and RequestStream.WriteAsync() described in the issue. Compare the exceptions observed after the consumer is too slow, and determine whether the differing failure notifications are expected. Done means the behavior is clarified or the issue is narrowed to a reproducible failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100