Skip to content

Commit d0588f1

Browse files
santigimenorvagg
authored andcommitted
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. PR-URL: #19856 Fixes: #19804 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 1e25f00 commit d0588f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/sequential/test-http-client-timeout-agent.js renamed to test/parallel/test-http-client-timeout-agent.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ const server = http.createServer(function(req, res) {
4848

4949
server.listen(0, options.host, function() {
5050
options.port = this.address().port;
51-
let req;
5251

5352
for (requests_sent = 0; requests_sent < 30; requests_sent += 1) {
5453
options.path = `/${requests_sent}`;
55-
req = http.request(options);
54+
const req = http.request(options);
5655
req.id = requests_sent;
5756
req.on('response', function(res) {
5857
res.on('data', function(data) {
@@ -61,6 +60,7 @@ server.listen(0, options.host, function() {
6160
res.on('end', function(data) {
6261
console.log(`res#${this.req.id} end`);
6362
requests_done += 1;
63+
req.destroy();
6464
});
6565
});
6666
req.on('close', function() {

0 commit comments

Comments
 (0)