-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.
Description
Aborting a pending request (whose response is not read yet) causes http.globalAgent.maxSockets to not being respected for future requests.
Specifically:
- the response must contain some data;
- there must be a
'response'listener registered for the requests.
I can reproduce the issue with the following:
client.js:
var http = require('http');
http.globalAgent.maxSockets = 3;
for (var i = 0; i < 100; i++) {
var request = http.get('http://127.0.0.1:8080', function () {
// just register a listener...
});
request.setTimeout(1000, function () {
console.log('T');
this.abort();
});
}server.js:
require('http').createServer(function (reqest, response) {
console.log('R');
response.end('hello');
}).listen(8080);Run server.js then client.js; the output of the former is:
R
R
R
# 1s timeout here...
R
R
R
R
R
R
# 1s timeout here...
R
R
R
R
R
R
R
R
R
R
R
R
# 1s timeout here...
[...]
# up to 100
I was expecting groups of three requests each, instead of: 100 = 3 + 6 + 12 + 24 + 48 + 7.
The output of client.js reflects the one of server.js.
This happen at least with v4.1.1 and v5.1.0.
I apologize if the above is the intended behavior and I'm just misunderstanding request.abort() and agent.maxSockets.
Metadata
Metadata
Assignees
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.