diff --git a/rpc/lib/client/ws_client.go b/rpc/lib/client/ws_client.go index 3f98fd51..e4ed442e 100644 --- a/rpc/lib/client/ws_client.go +++ b/rpc/lib/client/ws_client.go @@ -170,9 +170,11 @@ func (c *WSClient) OnStop() {} // channel is closed. func (c *WSClient) Stop() error { err := c.BaseService.Stop() - // only close user-facing channels when we can't write to them - c.wg.Wait() - close(c.ResponsesCh) + if err == nil { + // only close user-facing channels when we can't write to them + c.wg.Wait() + close(c.ResponsesCh) + } return err }