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 <info@bnoordhuis.nl>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
dnakamura authored and Myles Borins committed Jan 19, 2016
1 parent 9808521 commit 761af37
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 761af37

Please sign in to comment.