Skip to content

Commit 5c7fd50

Browse files
committed
stream: the position of _read() is wrong
Fixes: #33940
1 parent 13d0de5 commit 5c7fd50

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/internal/fs/streams.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ ReadStream.prototype._read = function(n) {
255255
if (er) {
256256
errorOrDestroy(this, er);
257257
} else if (bytesRead > 0) {
258+
if (this.pos !== undefined) {
259+
this.pos += bytesRead;
260+
}
261+
258262
this.bytesRead += bytesRead;
259263

260264
if (bytesRead !== buf.length) {
@@ -271,10 +275,6 @@ ReadStream.prototype._read = function(n) {
271275
this.push(null);
272276
}
273277
});
274-
275-
if (this.pos !== undefined) {
276-
this.pos += n;
277-
}
278278
};
279279

280280
ReadStream.prototype._destroy = function(err, cb) {

0 commit comments

Comments
 (0)