Unwrap proto errors in streaming client

Allows clients to properly detect context cancellation

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan
2022-12-02 11:24:25 -08:00
parent 51195ad099
commit 8a25fa584f
3 changed files with 29 additions and 8 deletions

View File

@@ -157,14 +157,14 @@ func ReceiveStream(ctx context.Context, stream streaming.Stream) io.Reader {
// check window update error after recv, stream may be complete
if werr = stream.Send(any); werr == nil {
window += windowSize
} else if werr == io.EOF {
} else if errors.Is(werr, io.EOF) {
// TODO: Why does send return EOF here
werr = nil
}
}
any, err := stream.Recv()
if err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) {
err = nil
} else {
err = fmt.Errorf("received failed: %w", err)