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