Skip to content

Commit 23e7703

Browse files
santigimenoevanlucas
authored andcommitted
test: fix http-many-ended-pipelines flakiness
It can happen that the HTTP connection is closed before the server has received all the requests, thus the server close condition is never reached. To solve this, close the server when the socket is fully closed. PR-URL: #4041 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
1 parent 84dea1b commit 23e7703

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/parallel/test-http-many-ended-pipelines.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ var http = require('http');
1313
var net = require('net');
1414

1515
var numRequests = 20;
16-
var done = 0;
16+
var first = false;
1717

1818
var server = http.createServer(function(req, res) {
19-
res.end('ok');
19+
if (!first) {
20+
first = true;
21+
req.socket.on('close', function() {
22+
server.close();
23+
});
24+
}
2025

26+
res.end('ok');
2127
// Oh no! The connection died!
2228
req.socket.destroy();
23-
if (++done == numRequests)
24-
server.close();
2529
});
2630

2731
server.listen(common.PORT);

0 commit comments

Comments
 (0)