diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 906625d0a499ec..91ca52c4e6e52f 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -125,8 +125,8 @@ function Agent(options) { return; } - let freeSockets = this.freeSockets[name]; - const freeLen = freeSockets ? freeSockets.length : 0; + const freeSockets = this.freeSockets[name] || []; + const freeLen = freeSockets.length; let count = freeLen; if (this.sockets[name]) count += this.sockets[name].length; @@ -138,7 +138,6 @@ function Agent(options) { return; } - freeSockets = freeSockets || []; this.freeSockets[name] = freeSockets; socket[async_id_symbol] = -1; socket._httpMessage = null;