From 993b1cbc6d132e64b92747499bea4292ed5a3b06 Mon Sep 17 00:00:00 2001 From: idandagan1 Date: Wed, 6 Dec 2017 21:57:13 +0200 Subject: [PATCH] test: use Countdown in http test PR-URL: https://github.com/nodejs/node/pull/17506 Reviewed-By: Anatoli Papirovski Reviewed-By: Jon Moss Reviewed-By: Luigi Pinca --- .../test-http-incoming-pipelined-socket-destroy.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http-incoming-pipelined-socket-destroy.js b/test/parallel/test-http-incoming-pipelined-socket-destroy.js index 7c15339785137b..8e63bdb8a9bbd2 100644 --- a/test/parallel/test-http-incoming-pipelined-socket-destroy.js +++ b/test/parallel/test-http-incoming-pipelined-socket-destroy.js @@ -21,11 +21,13 @@ 'use strict'; const common = require('../common'); +const Countdown = require('../common/countdown'); const http = require('http'); const net = require('net'); const seeds = [ 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 ]; +const countdown = new Countdown(seeds.length, () => server.close()); // Set up some timing issues where sockets can be destroyed // via either the req or res. @@ -72,11 +74,8 @@ function generator(seeds) { server.listen(0, common.mustCall(function() { const client = net.connect({ port: this.address().port }); - let done = 0; server.on('requestDone', function() { - if (++done === seeds.length) { - server.close(); - } + countdown.dec(); }); // immediately write the pipelined requests.