diff --git a/lib/net.js b/lib/net.js index 40991aa6fb8a64..65d57b2b89545b 100644 --- a/lib/net.js +++ b/lib/net.js @@ -476,7 +476,7 @@ Socket.prototype.destroySoon = function() { Socket.prototype._destroy = function(exception, cb) { debug('destroy'); - function fireErrorCallbacks(self) { + function fireErrorCallbacks(self, exception, cb) { if (cb) cb(exception); if (exception && !self._writableState.errorEmitted) { process.nextTick(emitErrorNT, self, exception); @@ -486,7 +486,7 @@ Socket.prototype._destroy = function(exception, cb) { if (this.destroyed) { debug('already destroyed, fire error callbacks'); - fireErrorCallbacks(this); + fireErrorCallbacks(this, exception, cb); return; } @@ -518,7 +518,7 @@ Socket.prototype._destroy = function(exception, cb) { // to make it re-entrance safe in case Socket.prototype.destroy() // is called within callbacks this.destroyed = true; - fireErrorCallbacks(this); + fireErrorCallbacks(this, exception, cb); if (this._server) { COUNTER_NET_SERVER_CONNECTION_CLOSE(this);