grpc / grpc-dotnet

gRPC for .NET
Apache License 2.0
4.22k stars 776 forks source link

Proper way to be notified about stream failure #2540

Open ricsiLT opened 2 months ago

ricsiLT commented 2 months ago

Hi,

Recently I've run into the following situation:

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.