From 0612c6cc4b577d6afde5c5df917653193db30381 Mon Sep 17 00:00:00 2001 From: Christian Schnell Date: Fri, 20 Dec 2024 18:24:11 +0100 Subject: [PATCH] stop reconnecting websocket after NetworkAdapter.destroy() was called (#1198) --- src/browser/network.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/browser/network.js b/src/browser/network.js index 7972c7eb41..22d58f26bb 100644 --- a/src/browser/network.js +++ b/src/browser/network.js @@ -25,6 +25,7 @@ function NetworkAdapter(url, bus, id) this.reconnect_interval = 10000; this.last_connect_attempt = Date.now() - this.reconnect_interval; this.send_queue_limit = 64; + this.destroyed = false; this.bus.register("net" + this.id + "-send", function(data) { @@ -44,8 +45,11 @@ NetworkAdapter.prototype.handle_close = function(e) { //console.log("onclose", e); - this.connect(); - setTimeout(this.connect.bind(this), this.reconnect_interval); + if(!this.destroyed) + { + this.connect(); + setTimeout(this.connect.bind(this), this.reconnect_interval); + } }; NetworkAdapter.prototype.handle_open = function(e) @@ -67,6 +71,7 @@ NetworkAdapter.prototype.handle_error = function(e) NetworkAdapter.prototype.destroy = function() { + this.destroyed = true; if(this.socket) { this.socket.close();