diff options
Diffstat (limited to 'lib/fs.js')
-rw-r--r-- | lib/fs.js | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1367,7 +1367,10 @@ ReadStream.prototype._emitData = function(d) { ReadStream.prototype.destroy = function(cb) { var self = this; - if (!this.readable) return; + if (!this.readable) { + if (cb) process.nextTick(function() { cb(null); }); + return; + } this.readable = false; function close() { @@ -1570,7 +1573,10 @@ WriteStream.prototype.end = function(data, encoding, cb) { WriteStream.prototype.destroy = function(cb) { var self = this; - if (!this.writable) return; + if (!this.writable) { + if (cb) process.nextTick(function() { cb(null); }); + return; + } this.writable = false; function close() { |