Hi there,
Cancellation should really be considered an out-of-band unclean termination of the stream. There isn't even a library-level guarantee at that point of what has been seen or not seen, and a cancellation terminates both sides of the stream at the transport level so that the server can't even send trailing metadata on the wire (though you still have to give status for the RPC for library-level cleanup). So I'd really recommend not using it if you want a clean recovery. Instead, consider changing your application-layer protocol. For example, if you're using protobuf, you could change your message type to be a oneof between your existing message type and a new "CleanCancel" message so that way the Read will succeed and then you'll see that it was a CleanCancel message. If you're using the generic API as many proxies are likely to do, you could just instrument your proxy messages with an enum at the beginning to specify the type of message being sent and that would identify the cancellation. In other words, if you want a clean, graceful termination you need to do it via messages and not cancellation.
- vjpai