From 1e233b765308258a655e66d04117fe32858b681c Mon Sep 17 00:00:00 2001 From: Bob McElrath Date: Tue, 28 Feb 2017 13:36:20 -0500 Subject: [PATCH] Don't increment bytes counter and unref timers if socket is paused --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d922764..67ae23d 100644 --- a/index.js +++ b/index.js @@ -816,15 +816,15 @@ Socket.prototype._onReceive = function (data) { var buffer = Buffer.from(data) var offset = this.bytesRead - this.bytesRead += buffer.length - this._unrefTimer() - if (this.ondata) { console.error('socket.ondata = func is non-standard, use socket.on(\'data\', func)') this.ondata(buffer, offset, this.bytesRead) } if (!this.push(buffer)) { // if returns false, then apply backpressure - chrome.sockets.tcp.setPaused(this.id, true) + chrome.sockets.tcp.setPaused(this.id, true) // onReceive will be called again with this data + } else { + this.bytesRead += buffer.length + this._unrefTimer() } }