Skip to content

Commit 6723619

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 8e73a06 commit 6723619

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
@@ -29,6 +29,7 @@ const assert = require('assert');
2929

3030
consthttp=require('http');
3131
constnet=require('net');
32+
constCountdown=require('../common/countdown');
3233

3334
// Create a TCP server
3435
constsrv=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-
letleft=headers.length;
64+
constcountdown=newCountdown(headers.length,()=>srv.close());
65+
6466
headers.forEach(function(h){
6567
constreq=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)