From 0c75464094ae8f82523df042d8593fe6681cab3b Mon Sep 17 00:00:00 2001 From: Mitra Ardron Date: Mon, 1 Jul 2019 18:40:44 +1000 Subject: [PATCH] Fix HTTP heartbeat timer stopping --- TransportHTTP.js | 8 +++++--- httptools.js | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/TransportHTTP.js b/TransportHTTP.js index 0b49a25..e81455c 100644 --- a/TransportHTTP.js +++ b/TransportHTTP.js @@ -100,7 +100,8 @@ class TransportHTTP extends Transport { startHeartbeat({delay=undefined, statusCB=undefined}) { if (delay) { - this.heartbeatTimer = setInterval(() => { + debug("HTTP Starting Heartbeat") + this.HTTPheartbeatTimer = setInterval(() => { this.updateStatus((err, res)=>{ // Pings server and sets status if (statusCB) statusCB(this); // repeatedly call callback if supplies }, (unusedErr, unusedRes)=>{}); // Dont wait for status to complete @@ -108,8 +109,9 @@ class TransportHTTP extends Transport { } } stopHeartbeat() { - if (this.heartbeatTimer) { - clearInterval(this.hearbeatTimer);} + if (this.HTTPheartbeatTimer) { + debug("HTTP stopping heartbeat"); + clearInterval(this.HTTPheartbeatTimer);} } stop(refreshstatus, cb) { this.stopHeartbeat(); diff --git a/httptools.js b/httptools.js index 752af65..10b0b77 100644 --- a/httptools.js +++ b/httptools.js @@ -29,9 +29,9 @@ function queueSetup({concurrency}) { if (task.loopguard === ((typeof window != "undefined") && window.loopguard)) { fetch(task.req) .then(res => { - debug("Fetch of %s succeded", task.what); + debug("Fetch of %s succeeded", task.what); httpTaskQueue.concurrency = Math.min(httpTaskQueue.concurrency+1, httpTaskQueue.running()+6); - debug("Raising concurrency to %s", httpTaskQueue.concurrency); + //debug("Raising concurrency to %s", httpTaskQueue.concurrency); cb(null); task.cb(null, res); }) @@ -39,7 +39,7 @@ function queueSetup({concurrency}) { // Adjust concurrency, dont go below running number (which is running-1 because this failed task counts) // and we know browser doesnt complain below 6 httpTaskQueue.concurrency = Math.max(httpTaskQueue.concurrency-1, 6, httpTaskQueue.running()-1); - debug("Dropping concurrency to %s", httpTaskQueue.concurrency); + //debug("Dropping concurrency to %s", httpTaskQueue.concurrency); cb(err); if (--task.count > 0) { debug("Retrying fetch of %s in %s ms: %s", task.what, task.ms, err.message);