From e50db63c7d31b5c355abb433b98c7a84fdaf442c Mon Sep 17 00:00:00 2001 From: Philipp Seith <6890503+philippseith@users.noreply.github.com> Date: Thu, 18 Nov 2021 10:39:00 +0100 Subject: [PATCH] fix: Leak in AutoReconnect --- client.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index 59984804..5d2c4123 100644 --- a/client.go +++ b/client.go @@ -183,16 +183,15 @@ func (c *client) run() error { // Run the loop err = loop.Run(isLoopConnected) + if err == nil { + err = loop.hubConn.Close("", false) // allowReconnect value is ignored as servers never initiate a connection + } + // Reset conn to allow reconnecting c.mx.Lock() c.conn = nil c.mx.Unlock() - if err != nil { - return err - } - err = loop.hubConn.Close("", false) // allowReconnect value is ignored as servers never initiate a connection - return err }