The (undocumented) callback argument to .destroy() was not called if the
stream was no longer readable / writable.
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() {
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() {
file2.destroy(function(err) {
assert.ok(!err);
callbacks.destroy++;
+
+ file2.destroy(function(err) {
+ assert.ok(!err);
+ callbacks.destroy++;
+ });
});
var file3 = fs.createReadStream(fn, {encoding: 'utf8'});
process.on('exit', function() {
assert.equal(1, callbacks.open);
assert.equal(1, callbacks.end);
- assert.equal(1, callbacks.destroy);
+ assert.equal(2, callbacks.destroy);
assert.equal(2, callbacks.close);