Skip to content

Commit 23edd08

Browse files
idandagan1gibfahn
authored andcommitted
test: use Countdown in http test
PR-URL: #17506 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 67c526f commit 23edd08

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

test/parallel/test-http-incoming-pipelined-socket-destroy.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use strict';
22
const common = require('../common');
3+
const Countdown = require('../common/countdown');
34

45
const http = require('http');
56
const net = require('net');
67

78
const seeds = [ 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 ];
9+
const countdown = new Countdown(seeds.length, () => server.close());
810

911
// Set up some timing issues where sockets can be destroyed
1012
// via either the req or res.
@@ -51,11 +53,8 @@ function generator(seeds) {
5153

5254
server.listen(0, common.mustCall(function() {
5355
const client = net.connect({ port: this.address().port });
54-
let done = 0;
5556
server.on('requestDone', function() {
56-
if (++done === seeds.length) {
57-
server.close();
58-
}
57+
countdown.dec();
5958
});
6059

6160
// immediately write the pipelined requests.

0 commit comments

Comments
 (0)