diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index 57c2304fca82cc..b388bad80c74a5 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -255,6 +255,10 @@ ReadStream.prototype._read = function(n) { if (er) { errorOrDestroy(this, er); } else if (bytesRead > 0) { + if (this.pos !== undefined) { + this.pos += bytesRead; + } + this.bytesRead += bytesRead; if (bytesRead !== buf.length) { @@ -271,10 +275,6 @@ ReadStream.prototype._read = function(n) { this.push(null); } }); - - if (this.pos !== undefined) { - this.pos += n; - } }; ReadStream.prototype._destroy = function(err, cb) {