Skip to content

Commit 317180f

Browse files
Sebastian Plesciucrefack
authored andcommitted
test: fix flaky test-https-client-get-url
Fixed test-https-client-get-url by waiting on HTTPS GET requests to finish before closing the server. PR-URL: #12876Fixes: #12873 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent e1cabf6 commit 317180f

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎test/parallel/test-https-client-get-url.js‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,21 @@ const options = {
4141
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
4242
};
4343

44-
constserver=https.createServer(options,common.mustCall(function(req,res){
44+
constserver=https.createServer(options,common.mustCall((req,res)=>{
4545
assert.strictEqual('GET',req.method);
4646
assert.strictEqual('/foo?bar',req.url);
4747
res.writeHead(200,{'Content-Type': 'text/plain'});
4848
res.write('hello\n');
4949
res.end();
50-
server.close();
5150
},3));
5251

53-
server.listen(0,function(){
54-
constu=`https://127.0.0.1:${this.address().port}/foo?bar`;
55-
https.get(u);
56-
https.get(url.parse(u));
57-
https.get(newURL(u));
58-
});
52+
server.listen(0,common.mustCall(()=>{
53+
constu=`https://${common.localhostIPv4}:${server.address().port}/foo?bar`;
54+
https.get(u,common.mustCall(()=>{
55+
https.get(url.parse(u),common.mustCall(()=>{
56+
https.get(newURL(u),common.mustCall(()=>{
57+
server.close();
58+
}));
59+
}));
60+
}));
61+
}));

0 commit comments

Comments
 (0)