Compare commits

..

1 commit

Author SHA1 Message Date
2352156ee9 [#301] rpc: Make client stream initialization get cancelled by dial timeout
All checks were successful
DCO / DCO (pull_request) Successful in 1m21s
Tests and linters / Tests (pull_request) Successful in 1m38s
Tests and linters / Lint (pull_request) Successful in 1m55s
* `c.conn` may be already invalidated but the rpc client can't detect this.
  `NewStream` may hang trying to open a stream with invalidated connection.
  Using timer with `dialTimeout` for `NewStream` fixes this problem.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
2024-12-05 16:30:57 +03:00

View file

@ -61,7 +61,8 @@ func (c *Client) Init(info common.CallMethodInfo, opts ...CallOption) (MessageRe
// would propagate to all subsequent read/write operations on the opened stream,
// which is not desired for the stream's lifecycle management.
dialTimeoutTimer := time.NewTimer(c.dialTimeout)
newStreamCh := make(chan interface{})
defer dialTimeoutTimer.Stop()
newStreamCh := make(chan struct{})
var stream grpc.ClientStream
var err error