From d1ef291c64e61d20b83c2c6d279193c7e59ab686 Mon Sep 17 00:00:00 2001
From: Dmitrii Stepanov <d.stepanov@yadro.com>
Date: Mon, 17 Feb 2025 15:55:30 +0300
Subject: [PATCH] [#334] rpc: Use DeadlineExceeded error when creating stream
 failed by timeout

According to https://pkg.go.dev/context#pkg-variables, ContextCancelled
should be returned when the context is canceled for some reason other
than its deadline passing. So creating gRPC stream with dial timeout fits
better for context.DeadlineExceeded.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
---
 api/rpc/client/init.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/api/rpc/client/init.go b/api/rpc/client/init.go
index 08a9925..834f5da 100644
--- a/api/rpc/client/init.go
+++ b/api/rpc/client/init.go
@@ -101,7 +101,7 @@ func (c *Client) initInternal(info common.CallMethodInfo, opts ...CallOption) (*
 		if res.stream != nil && res.err == nil {
 			_ = res.stream.CloseSend()
 		}
-		return nil, context.Canceled
+		return nil, context.DeadlineExceeded
 	case res = <-newStreamCh:
 	}