From 0dea37ee70ab8bfc082bfe980e11c02e92947d8a Mon Sep 17 00:00:00 2001 From: Joshua Humphries Date: Thu, 1 Nov 2018 14:32:56 -0400 Subject: [PATCH] on error reading request, bidi stream would hang (#63) --- invoke.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/invoke.go b/invoke.go index 39e8514..75acf6b 100644 --- a/invoke.go +++ b/invoke.go @@ -284,6 +284,9 @@ func invokeServerStream(ctx context.Context, stub grpcdynamic.Stub, md *desc.Met func invokeBidi(ctx context.Context, stub grpcdynamic.Stub, md *desc.MethodDescriptor, handler InvocationEventHandler, requestData RequestSupplier, req proto.Message) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + // invoke the RPC! str, err := stub.InvokeRpcBidiStream(ctx, md) @@ -318,6 +321,7 @@ func invokeBidi(ctx context.Context, stub grpcdynamic.Stub, md *desc.MethodDescr if err != nil { sendErr.Store(err) + cancel() } }() }