From 8b9dbdad272d58b3db7cfa8956dad6b7db5d7c0e Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 17 Feb 2011 17:38:36 -0800 Subject: [PATCH] Closes GH-687 Don't read fs read stream if not open --- lib/fs.js | 3 +++ test/simple/test-fs-read-stream.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/fs.js b/lib/fs.js index 62712d57f8..3eb31a99fc 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -921,6 +921,9 @@ ReadStream.prototype.resume = function() { this.buffer = null; } + // hasn't opened yet. + if (null == this.fd) return; + this._read(); }; diff --git a/test/simple/test-fs-read-stream.js b/test/simple/test-fs-read-stream.js index b152eed309..026afcb2a0 100644 --- a/test/simple/test-fs-read-stream.js +++ b/test/simple/test-fs-read-stream.js @@ -119,3 +119,8 @@ stream.on('data', function(chunk) { stream.on('end', function() { assert.equal('x', stream.data); }); + +// pause and then resume immediately. +var pauseRes = fs.createReadStream(rangeFile); +pauseRes.pause(); +pauseRes.resume();