Fix HTTP heartbeat timer stopping

This commit is contained in:
Mitra Ardron 2019-07-01 18:40:44 +10:00
parent 8b8f5d0b7c
commit 0c75464094
2 changed files with 8 additions and 6 deletions

View File

@ -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();

View File

@ -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);