-
Notifications
You must be signed in to change notification settings - Fork 794
Avoid throwing InvalidOpEx in server stream #1435
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Avoid throwing InvalidOpEx in server stream #1435
Conversation
… a gRPC server stream after the connection was closed
|
Hmmm, I disagree with what Grpc.Core is doing. Returning false instead of an error seems like an easy way for people to unknowingly ignore errors. Perhaps there should be a setting to opt-in to this behavior. People who are porting from Grpc.Core can enable it once on the server. |
The case here in the existing client-server implementation is that a Task is kept awaiting the server stream while the client disconnects, as the server must continue to accept any late-arriving client messages. On the Google server this simply returns false once the client closes the connection. |
The question is whether receiving cancellation from the client on the server side is an "error" that needs to be handled/reported. For some RPCs, the client cancelling the RPC is a "normal" mode of operation in the sense that the client announces that given streaming RPC is no longer needed (since e.g. a bidi call be be used to represent a sequence of "commands" sent by the client. Or if the RPC is used to send updates from the server, client cancelling the RPC is just a signal to stop sending updates). Throwing in requestStream.ReadNext() just make the code more complicated in case where cancelling the RPC is part of a normal workflow (and I agree that it makes migrating code from Grpc.Core more complicated, and we don't want that). I'd be in favor of changing the grpc-dotnet behavior or at least adding a knob to configure the behavior. |
Wouldn't
This makes sense to me too. However, why was this ever an |
Return false instead of throwing InvalidOperationException on read of a gRPC server stream after the connection was closed.
In porting a large application from the deprecated Google gRPC server to ASP.NET, this exception path required adding an additional catch where none had been needed before. Related to #1219 but not a complete fix for that issue.