diff --git a/lib/net.js b/lib/net.js index b04c65abd6fab6..5e653c61d2106c 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1495,13 +1495,6 @@ Server.prototype.getConnections = function(cb) { Server.prototype.close = function(cb) { - function onSlaveClose() { - if (--left !== 0) return; - - self._connections = 0; - self._emitCloseIfDrained(); - } - if (typeof cb === 'function') { if (!this._handle) { this.once('close', function() { @@ -1518,8 +1511,13 @@ Server.prototype.close = function(cb) { } if (this._usingSlaves) { - var self = this; var left = this._slaves.length; + const onSlaveClose = () => { + if (--left !== 0) return; + + this._connections = 0; + this._emitCloseIfDrained(); + }; // Increment connections to be sure that, even if all sockets will be closed // during polling of slaves, `close` event will be emitted only once.