Skip to content

Commit c9a4f4f

Browse files
mithunsasidharanMylesBorins
authored andcommitted
test: update test-http-upgrade-client to use countdown
PR-URL: #17339 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
1 parent 91d5416 commit c9a4f4f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/parallel/test-http-upgrade-client.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const assert = require('assert');
2929

3030
const http = require('http');
3131
const net = require('net');
32+
const Countdown = require('../common/countdown');
3233

3334
// Create a TCP server
3435
const srv = net.createServer(function(c) {
@@ -60,7 +61,8 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
6061
['Origin', 'http://www.websocket.org']
6162
]
6263
];
63-
let left = headers.length;
64+
const countdown = new Countdown(headers.length, () => srv.close());
65+
6466
headers.forEach(function(h) {
6567
const req = http.get({
6668
port: port,
@@ -87,8 +89,7 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
8789
assert.deepStrictEqual(expectedHeaders, res.headers);
8890

8991
socket.end();
90-
if (--left === 0)
91-
srv.close();
92+
countdown.dec();
9293
}));
9394
req.on('close', common.mustCall(function() {
9495
assert.strictEqual(sawUpgrade, true);

0 commit comments

Comments
 (0)