From 3f2078f4670d4be4f3996272422e98e1a8b49ada Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Fri, 6 Apr 2018 20:03:14 +0200 Subject: [PATCH] test: fix flaky http-client-timeout-agent 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: https://github.com/nodejs/node/issues/19804 --- .../test-http-client-timeout-agent.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename test/{sequential => parallel}/test-http-client-timeout-agent.js (97%) diff --git a/test/sequential/test-http-client-timeout-agent.js b/test/parallel/test-http-client-timeout-agent.js similarity index 97% rename from test/sequential/test-http-client-timeout-agent.js rename to test/parallel/test-http-client-timeout-agent.js index 9a974d4e5221da..8ce14f865c269c 100644 --- a/test/sequential/test-http-client-timeout-agent.js +++ b/test/parallel/test-http-client-timeout-agent.js @@ -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) { @@ -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() {