Fixe loopguard to return correctly; add info to statuses

This commit is contained in:
Mitra Ardron 2019-08-15 15:12:35 +10:00
parent eec42a6430
commit e4e8658536
2 changed files with 8 additions and 5 deletions

View File

@ -40,12 +40,12 @@ class Transports {
static async p_connectedNamesParm() { // Doesnt strictly need to be async, but for consistency with Proxy it has to be.
return (await this.p_connectedNames()).map(n => "transport="+n).join('&')
}
static statuses({connected=undefined}) { //TODO-API
static statuses({connected=undefined}) { //TODO-API (especially add info:)
/*
Return array of statuses,
connected: If true then only connected transports
*/
const ss = Transports._transports.map((t) => { return {"name": t.name, "status": t.status}});
const ss = Transports._transports.map((t) => { return {name: t.name, status: t.status, info: t.info}});
return connected ? ss.filter(s => !s.status) : ss;
}
static p_statuses(cb) {

View File

@ -38,15 +38,15 @@ function queueSetup({concurrency}) {
debug("Fetch of %s completed", task.what);
httpTaskQueue.concurrency = Math.min(httpTaskQueue.concurrency+1, httpTaskQueue.running()+6);
//debug("Raising concurrency to %s", httpTaskQueue.concurrency);
cb(null);
task.cb(null, res);
cb(null); // This is telling the queue that we are done
task.cb(null, res); // This is the caller of the task
})
.catch(err => {
// 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);
cb(err);
cb(err); // Tell queue done with an error
if (--task.count > 0) {
debug("Retrying fetch of %s in %s ms: %s", task.what, task.ms, err.message);
httpTaskQueue.push(task);
@ -61,7 +61,10 @@ function queueSetup({concurrency}) {
}
});
} else {
err = new Error(`Dropping fetch of ${task.what} as window changed from ${task.loopguard} to ${window.loopguard}`)
debug("Dropping fetch of %s as window changed from %s to %s", task.what, task.loopguard, window.loopguard);
task.cb(err); // Tell caller it failed
cb(err); // Tell queue it failed
}
}, concurrency)
}