Skip to content

Commit 660e6de

Browse files
mithunsasidharangibfahn
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 8f997c0 commit 660e6de

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const assert = require('assert');
88

99
const http = require('http');
1010
const net = require('net');
11+
const Countdown = require('../common/countdown');
1112

1213
// Create a TCP server
1314
const srv = net.createServer(function(c) {
@@ -39,7 +40,8 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
3940
['Origin', 'http://www.websocket.org']
4041
]
4142
];
42-
let left = headers.length;
43+
const countdown = new Countdown(headers.length, () => srv.close());
44+
4345
headers.forEach(function(h) {
4446
const req = http.get({
4547
port: port,
@@ -66,8 +68,7 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
6668
assert.deepStrictEqual(expectedHeaders, res.headers);
6769

6870
socket.end();
69-
if (--left === 0)
70-
srv.close();
71+
countdown.dec();
7172
}));
7273
req.on('close', common.mustCall(function() {
7374
assert.strictEqual(sawUpgrade, true);

0 commit comments

Comments
 (0)