From 2eb3cd5965cf34f6d6b21748daea520163b9c789 Mon Sep 17 00:00:00 2001 From: Denis Badurina Date: Wed, 26 Aug 2020 19:30:41 +0200 Subject: [PATCH] fix: reset connected/connecting state when disconnecting and disposing --- src/client.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/client.ts b/src/client.ts index bdc1353e..d6c7f3ea 100644 --- a/src/client.ts +++ b/src/client.ts @@ -245,6 +245,8 @@ export function createClient(options: ClientOptions): Client { // equal to 1 because this sink is the last one. // the deletion from the map happens afterwards if (Object.entries(subscribedSinks).length === 1) { + connected = false; + connecting = false; if (socket.readyState === WebSocket.OPEN) { socket.close(1000, 'Normal Closure'); } @@ -268,6 +270,8 @@ export function createClient(options: ClientOptions): Client { // if there is an active socket, close it with a normal closure if (socket && socket.readyState === WebSocket.OPEN) { + connected = false; + connecting = false; // TODO-db-200817 decide if `1001: Going Away` should be used instead socket.close(1000, 'Normal Closure'); socket = null;