diff --git a/test/parallel/test-http-set-cookies.js b/test/parallel/test-http-set-cookies.js index 44a5f47bbb3d03..c307bda73a3515 100644 --- a/test/parallel/test-http-set-cookies.js +++ b/test/parallel/test-http-set-cookies.js @@ -23,9 +23,9 @@ require('../common'); const assert = require('assert'); const http = require('http'); +const Countdown = require('../common/countdown'); -let nresponses = 0; - +const countdown = new Countdown(2, () => server.close()); const server = http.createServer(function(req, res) { if (req.url === '/one') { res.writeHead(200, [['set-cookie', 'A'], @@ -55,9 +55,7 @@ server.on('listening', function() { }); res.on('end', function() { - if (++nresponses === 2) { - server.close(); - } + countdown.dec(); }); }); @@ -72,14 +70,8 @@ server.on('listening', function() { }); res.on('end', function() { - if (++nresponses === 2) { - server.close(); - } + countdown.dec(); }); }); }); - -process.on('exit', function() { - assert.strictEqual(2, nresponses); -});