Skip to content

Commit 993b1cb

Browse files
idandagan1MylesBorins
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 0a0a56a commit 993b1cb

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121

2222
'use strict';
2323
const common = require('../common');
24+
const Countdown = require('../common/countdown');
2425

2526
const http = require('http');
2627
const net = require('net');
2728

2829
const seeds = [ 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 ];
30+
const countdown = new Countdown(seeds.length, () => server.close());
2931

3032
// Set up some timing issues where sockets can be destroyed
3133
// via either the req or res.
@@ -72,11 +74,8 @@ function generator(seeds) {
7274

7375
server.listen(0, common.mustCall(function() {
7476
const client = net.connect({ port: this.address().port });
75-
let done = 0;
7677
server.on('requestDone', function() {
77-
if (++done === seeds.length) {
78-
server.close();
79-
}
78+
countdown.dec();
8079
});
8180

8281
// immediately write the pipelined requests.

0 commit comments

Comments
 (0)