Skip to content

Commit 323ffac

Browse files
chungngoopsgibfahn
authored andcommitted
test: update test/parallel/test-http-pipe-fs.js to use countdown
PR-URL: #17346 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 279d844 commit 323ffac

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

‎test/parallel/test-http-pipe-fs.js‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const common = require('../common');
2424
consthttp=require('http');
2525
constfs=require('fs');
2626
constpath=require('path');
27+
constCountdown=require('../common/countdown');
28+
constNUMBER_OF_STREAMS=2;
29+
30+
constcountdown=newCountdown(NUMBER_OF_STREAMS,()=>server.close());
2731

2832
common.refreshTmpDir();
2933

@@ -39,27 +43,23 @@ const server = http.createServer(common.mustCall(function(req, res){
3943
},2)).listen(0,function(){
4044
http.globalAgent.maxSockets=1;
4145

42-
for(leti=0;i<2;++i){
43-
(function(i){
44-
constreq=http.request({
45-
port: server.address().port,
46-
method: 'POST',
47-
headers: {
48-
'Content-Length': 5
49-
}
50-
},function(res){
51-
res.on('end',function(){
52-
console.error(`res${i} end`);
53-
if(i===2){
54-
server.close();
55-
}
56-
});
57-
res.resume();
58-
});
59-
req.on('socket',function(s){
60-
console.error(`req${i} start`);
46+
for(leti=0;i<NUMBER_OF_STREAMS;++i){
47+
constreq=http.request({
48+
port: server.address().port,
49+
method: 'POST',
50+
headers: {
51+
'Content-Length': 5
52+
}
53+
},function(res){
54+
res.on('end',function(){
55+
console.error(`res${i+1} end`);
56+
countdown.dec();
6157
});
62-
req.end('12345');
63-
}(i+1));
58+
res.resume();
59+
});
60+
req.on('socket',function(s){
61+
console.error(`req${i+1} start`);
62+
});
63+
req.end('12345');
6464
}
6565
});

0 commit comments

Comments
(0)