From c6b2334fa370c38fc6f03b4ecc65ea8a7cd342d5 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 6 Nov 2017 13:23:51 -0500 Subject: [PATCH] check for error when stopping WSClient --- rpc/lib/client/ws_client.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 }