From ec8ff679dc606ed31f9f0a5fb88c7542f514ffc3 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 13 Mar 2018 15:41:01 -0400 Subject: [PATCH] Revert "fs: fix options.end of fs.ReadStream()" This reverts commit b343cb60e1dce2d25432f9efb7bb6e65f8333ee8. Some people were relying on the behavior of this.start being able to be undefined, whereas after the change it is being set to 0. Refs: https://github.com/nodejs/node/issues/19240 Refs: https://github.com/nodejs/node/pull/18121 --- lib/fs.js | 3 +-- test/parallel/test-fs-read-stream.js | 14 -------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index bfd085b4213881..32ef568c1a7185 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1950,8 +1950,7 @@ function ReadStream(path, options) { this.flags = options.flags === undefined ? 'r' : options.flags; this.mode = options.mode === undefined ? 0o666 : options.mode; - this.start = typeof this.fd !== 'number' && options.start === undefined ? - 0 : options.start; + this.start = options.start; this.end = options.end; this.autoClose = options.autoClose === undefined ? true : options.autoClose; this.pos = undefined; diff --git a/test/parallel/test-fs-read-stream.js b/test/parallel/test-fs-read-stream.js index 6748c68b52596c..04c10b5a4415c1 100644 --- a/test/parallel/test-fs-read-stream.js +++ b/test/parallel/test-fs-read-stream.js @@ -157,20 +157,6 @@ assert.throws(function() { })); } -{ - // Verify that end works when start is not specified. - const stream = new fs.createReadStream(rangeFile, { end: 1 }); - stream.data = ''; - - stream.on('data', function(chunk) { - stream.data += chunk; - }); - - stream.on('end', common.mustCall(function() { - assert.strictEqual('xy', stream.data); - })); -} - { // pause and then resume immediately. const pauseRes = fs.createReadStream(rangeFile);