From 3a0cb8fcae31844fd576c458065a611d88d9c211 Mon Sep 17 00:00:00 2001 From: Mithun Sasidharan Date: Wed, 22 Nov 2017 15:39:07 +0530 Subject: [PATCH] test: refactored http test to use countdown PR-URL: https://github.com/nodejs/node/pull/17241 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Anatoli Papirovski Reviewed-By: Anna Henningsen --- test/parallel/test-http-end-throw-socket-handling.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-end-throw-socket-handling.js b/test/parallel/test-http-end-throw-socket-handling.js index cb4f125948a3c9..134938ef09c7bd 100644 --- a/test/parallel/test-http-end-throw-socket-handling.js +++ b/test/parallel/test-http-end-throw-socket-handling.js @@ -1,5 +1,6 @@ 'use strict'; const common = require('../common'); +const Countdown = require('../common/countdown'); // Make sure that throwing in 'end' handler doesn't lock // up the socket forever. @@ -8,10 +9,10 @@ const common = require('../common'); // the same, we should not be so brittle and easily broken. const http = require('http'); +const countdown = new Countdown(10, () => server.close()); -let n = 0; const server = http.createServer((req, res) => { - if (++n === 10) server.close(); + countdown.dec(); res.end('ok'); });