Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/tls.js
@@ -645,12 +645,15 @@ CryptoStream.prototype.destroySoon = function(err) {
// Wait for both `finish` and `end` events to ensure that all data that
// was written on this side was read from the other side.
var self = this;
var waiting = 2;
var waiting = 1;
function finish() {
if (--waiting === 0) self.destroy();
}
this._opposite.once('end', finish);
this.once('finish', finish);
if (!this._finished) {
this.once('finish', finish);
++waiting;
}
}
};