Skip to content

Commit

Permalink
test: fix flaky http-client-timeout-agent
Browse files Browse the repository at this point in the history
Close the connection immediately after receiving the `end` event to
avoid that the `timeout` event is fired before the connection closes
gracefully.
Move the test back to parallel.

Fixes: nodejs#19804
  • Loading branch information
santigimeno committed Apr 7, 2018
1 parent 0ac6ced commit 3f2078f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ const server = http.createServer(function(req, res) {

server.listen(0, options.host, function() {
options.port = this.address().port;
let req;

for (requests_sent = 0; requests_sent < 30; requests_sent += 1) {
options.path = `/${requests_sent}`;
req = http.request(options);
const req = http.request(options);
req.id = requests_sent;
req.on('response', function(res) {
res.on('data', function(data) {
Expand All @@ -59,6 +58,7 @@ server.listen(0, options.host, function() {
res.on('end', function(data) {
console.log(`res#${this.req.id} end`);
requests_done += 1;
req.destroy();
});
});
req.on('close', function() {
Expand Down

0 comments on commit 3f2078f

Please sign in to comment.