diff --git a/rpc/grpc/init.go b/rpc/grpc/init.go index 9cf41d7..31a2ba7 100644 --- a/rpc/grpc/init.go +++ b/rpc/grpc/init.go @@ -57,10 +57,13 @@ func (w *streamWrapper) withTimeout(closure func() error) error { close(ch) }() + tt := time.NewTimer(w.timeout) + select { case err := <-ch: + tt.Stop() return err - case <-time.After(w.timeout): + case <-tt.C: w.cancel() return context.DeadlineExceeded }