From 7dd180eb83bf8b92e5fb70b874f1ae835d686b7b Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 28 Nov 2017 19:59:56 -0500 Subject: [PATCH] Properly lock before the close check --- pubsub.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pubsub.go b/pubsub.go index 87c5933..377eb88 100644 --- a/pubsub.go +++ b/pubsub.go @@ -118,6 +118,8 @@ func (t *TwitchPubSub) Close() error { t.listening = nil } + t.Lock() + if t.wsConn != nil { // To cleanly close a connection, a client should send a close // frame and wait for the server to close the connection.