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 <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
santigimeno authored and BridgeAR committed Apr 9, 2018
1 parent 8788046 commit 5b8c62c
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 5b8c62c

Please sign in to comment.