From 95aa340ece1df079cf0bcf34bd8b5b93cffc2019 Mon Sep 17 00:00:00 2001 From: Devin Nakamura Date: Fri, 18 Dec 2015 10:50:11 -0500 Subject: [PATCH] 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. --- test/gc/test-http-client-onerror.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index 98d046e180f11b..7e50683c6633e5 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 ++;