Skip to content

Commit f68f86c

Browse files
dnakamuraFishrock123
authored andcommitted
test: fix race condition in test-http-client-onerror
Occasionally test-http-client-onerror will fail with a refused connection. This patch fixes the possibility that connections will be attempted before server is listening. PR-URL: #4346 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent ec0b636 commit f68f86c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/gc/test-http-client-onerror.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ console.log('We should do ' + todo + ' requests');
2222

2323
var http = require('http');
2424
var server = http.createServer(serverHandler);
25-
server.listen(PORT, getall);
25+
server.listen(PORT, runTest);
2626

2727
function getall() {
2828
if (count >= todo)
@@ -51,8 +51,10 @@ function getall() {
5151
setImmediate(getall);
5252
}
5353

54-
for (var i = 0; i < 10; i++)
55-
getall();
54+
function runTest() {
55+
for (var i = 0; i < 10; i++)
56+
getall();
57+
}
5658

5759
function afterGC() {
5860
countGC ++;

0 commit comments

Comments
 (0)