mirror of
https://github.com/fluencelabs/dweb-transports
synced 2025-03-15 18:30:49 +00:00
Fix HTTP heartbeat timer stopping
This commit is contained in:
parent
8b8f5d0b7c
commit
0c75464094
@ -100,7 +100,8 @@ class TransportHTTP extends Transport {
|
|||||||
|
|
||||||
startHeartbeat({delay=undefined, statusCB=undefined}) {
|
startHeartbeat({delay=undefined, statusCB=undefined}) {
|
||||||
if (delay) {
|
if (delay) {
|
||||||
this.heartbeatTimer = setInterval(() => {
|
debug("HTTP Starting Heartbeat")
|
||||||
|
this.HTTPheartbeatTimer = setInterval(() => {
|
||||||
this.updateStatus((err, res)=>{ // Pings server and sets status
|
this.updateStatus((err, res)=>{ // Pings server and sets status
|
||||||
if (statusCB) statusCB(this); // repeatedly call callback if supplies
|
if (statusCB) statusCB(this); // repeatedly call callback if supplies
|
||||||
}, (unusedErr, unusedRes)=>{}); // Dont wait for status to complete
|
}, (unusedErr, unusedRes)=>{}); // Dont wait for status to complete
|
||||||
@ -108,8 +109,9 @@ class TransportHTTP extends Transport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
stopHeartbeat() {
|
stopHeartbeat() {
|
||||||
if (this.heartbeatTimer) {
|
if (this.HTTPheartbeatTimer) {
|
||||||
clearInterval(this.hearbeatTimer);}
|
debug("HTTP stopping heartbeat");
|
||||||
|
clearInterval(this.HTTPheartbeatTimer);}
|
||||||
}
|
}
|
||||||
stop(refreshstatus, cb) {
|
stop(refreshstatus, cb) {
|
||||||
this.stopHeartbeat();
|
this.stopHeartbeat();
|
||||||
|
@ -29,9 +29,9 @@ function queueSetup({concurrency}) {
|
|||||||
if (task.loopguard === ((typeof window != "undefined") && window.loopguard)) {
|
if (task.loopguard === ((typeof window != "undefined") && window.loopguard)) {
|
||||||
fetch(task.req)
|
fetch(task.req)
|
||||||
.then(res => {
|
.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);
|
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);
|
cb(null);
|
||||||
task.cb(null, res);
|
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)
|
// Adjust concurrency, dont go below running number (which is running-1 because this failed task counts)
|
||||||
// and we know browser doesnt complain below 6
|
// and we know browser doesnt complain below 6
|
||||||
httpTaskQueue.concurrency = Math.max(httpTaskQueue.concurrency-1, 6, httpTaskQueue.running()-1);
|
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);
|
cb(err);
|
||||||
if (--task.count > 0) {
|
if (--task.count > 0) {
|
||||||
debug("Retrying fetch of %s in %s ms: %s", task.what, task.ms, err.message);
|
debug("Retrying fetch of %s in %s ms: %s", task.what, task.ms, err.message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user