From ea2ceb731ca7dc6f2a11e501894adabf1cb4d20a Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 25 Sep 2012 11:15:44 -0700 Subject: test: Fix premature close in test-http-client-timeout-agent --- test/simple/test-http-client-timeout-agent.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/simple/test-http-client-timeout-agent.js b/test/simple/test-http-client-timeout-agent.js index d3b30ea8e0..79d0a24242 100644 --- a/test/simple/test-http-client-timeout-agent.js +++ b/test/simple/test-http-client-timeout-agent.js @@ -78,9 +78,16 @@ server.listen(options.port, options.host, function() { }); req.end(); } - setTimeout(function() { - server.close(); - }, 150); + + setTimeout(function maybeDone() { + if (requests_done >= requests_sent) { + setTimeout(function() { + server.close(); + }, 100); + } else { + setTimeout(maybeDone, 100); + } + }, 100); }); process.on('exit', function() { -- cgit v1.2.3