Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 23e7703

Browse filesBrowse 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 <info@bnoordhuis.nl> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
1 parent 84dea1b commit 23e7703
Copy full SHA for 23e7703

File tree

Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-http-many-ended-pipelines.js
+8-4Lines changed: 8 additions & 4 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.