Skip to content

Commit

Permalink
test: fix race condition in test-http-client-onerror
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dnakamura authored and Fishrock123 committed Jan 6, 2016
1 parent ec0b636 commit f68f86c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/gc/test-http-client-onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ console.log('We should do ' + todo + ' requests');

var http = require('http');
var server = http.createServer(serverHandler);
server.listen(PORT, getall);
server.listen(PORT, runTest);

function getall() {
if (count >= todo)
Expand Down Expand Up @@ -51,8 +51,10 @@ function getall() {
setImmediate(getall);
}

for (var i = 0; i < 10; i++)
getall();
function runTest() {
for (var i = 0; i < 10; i++)
getall();
}

function afterGC() {
countGC ++;
Expand Down

0 comments on commit f68f86c

Please sign in to comment.