From: Devin Nakamura Date: Fri, 18 Dec 2015 15:50:11 +0000 (-0500) Subject: test: fix race condition in test-http-client-onerror X-Git-Tag: v4.2.5~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=761af37d0ea075e0c29ca95c8117a628e310c25f;p=platform%2Fupstream%2Fnodejs.git 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: https://github.com/nodejs/node/pull/4346 Reviewed-By: Ben Noordhuis Reviewed-By: Brian White Reviewed-By: Johan Bergström Reviewed-By: James M Snell --- diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index 98d046e..7e50683 100644 --- a/test/gc/test-http-client-onerror.js +++ b/test/gc/test-http-client-onerror.js @@ -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) @@ -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 ++;