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.

PR-URL: #19856
Fixes: #19804
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
santigimeno authored and MylesBorins committed Aug 1, 2018
1 parent 9f3c414 commit 5436c7a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,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 @@ -61,6 +60,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 5436c7a

Please sign in to comment.