We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9cd73fb commit 4ef4a2dCopy full SHA for 4ef4a2d
lib/_http_agent.js
@@ -112,11 +112,12 @@ function Agent(options) {
112
if (this.sockets[name])
113
count += this.sockets[name].length;
114
115
- if (count > this.maxSockets) {
116
- socket.destroy();
117
- } else if (this.keepSocketAlive(socket)) {
+ if (this.keepSocketAlive(socket) &&
+ this.maxFreeSockets > 0 &&
+ count <= this.maxSockets) {
118
if (freeLen >= this.maxFreeSockets) {
119
- this.freeSockets[name].shift().destroy();
+ const oldest = this.freeSockets[name].shift();
120
+ oldest.destroy();
121
} else {
122
freeSockets = freeSockets || [];
123
this.freeSockets[name] = freeSockets;
0 commit comments