diff --git a/lib/net.js b/lib/net.js index 41a8e24c5a..81b679dab3 100644 --- a/lib/net.js +++ b/lib/net.js @@ -498,7 +498,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); @@ -508,7 +508,7 @@ Socket.prototype._destroy = function(exception, cb) { if (this.destroyed) { debug('already destroyed, fire error callbacks'); - fireErrorCallbacks(this); + fireErrorCallbacks(this, exception, cb); return; } @@ -540,7 +540,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);