Permalink
Browse files

test: refactored http test to use countdown

PR-URL: #17241
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information...
mithunsasidharan authored and gibfahn committed Nov 22, 2017
1 parent f3c1158 commit 3a0cb8fcae31844fd576c458065a611d88d9c211
Showing with 3 additions and 2 deletions.
  1. +3 −2 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');
});

0 comments on commit 3a0cb8f

Please sign in to comment.