Replace array by counter value in throttler

remotes/origin/middlewarify-query-controller
Javier Goizueta 5 years ago
parent 1e0ed7ee17
commit 936b7804de

@ -24,15 +24,15 @@ module.exports = class Throttler extends Transform {
this.bytesPerSecondHistory.shift();
}
const doesNotReachThreshold = [];
let doesNotReachThreshold = 0;
for (const bytesPerSecond of this.bytesPerSecondHistory) {
if (bytesPerSecond <= this.minimunBytesPerSecondThershold) {
doesNotReachThreshold.push(true);
doesNotReachThreshold += 1;
}
}
if (doesNotReachThreshold.length >= this.sampleLength) {
if (doesNotReachThreshold >= this.sampleLength) {
clearInterval(this._interval);
this.pgstream.emit('error', new Error('Connection closed by server: input data too slow'));
}

Loading…
Cancel
Save