From 6d1f8a31e4474f66cdee0ce19d8027569298b18a Mon Sep 17 00:00:00 2001 From: Mandeep Singh Date: Sun, 26 Nov 2017 19:29:34 +0530 Subject: [PATCH] test: Update test-http-parser-free to use countdown timer PR-URL: https://github.com/nodejs/node/pull/17322 Refs: https://github.com/nodejs/node/issues/17169 Reviewed-By: Jon Moss Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- test/parallel/test-http-parser-free.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-http-parser-free.js b/test/parallel/test-http-parser-free.js index 1ead3c14928d88..935d4d2ef443b0 100644 --- a/test/parallel/test-http-parser-free.js +++ b/test/parallel/test-http-parser-free.js @@ -23,13 +23,15 @@ require('../common'); const assert = require('assert'); const http = require('http'); +const Countdown = require('../common/countdown'); const N = 100; -let responses = 0; const server = http.createServer(function(req, res) { res.end('Hello'); }); +const countdown = new Countdown(N, () => server.close()); + server.listen(0, function() { http.globalAgent.maxSockets = 1; let parser; @@ -42,15 +44,9 @@ server.listen(0, function() { assert.strictEqual(req.parser, parser); } - if (++responses === N) { - server.close(); - } + countdown.dec(); res.resume(); }); })(i); } }); - -process.on('exit', function() { - assert.strictEqual(responses, N); -});