Skip to content

Commit 317180f

Browse files
Sebastian Plesciucrefack
Sebastian Plesciuc
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: #12876 Fixes: #12873 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent e1cabf6 commit 317180f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

+11-8
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-
const server = https.createServer(options, common.mustCall(function(req, res) {
44+
const server = 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-
const u = `https://127.0.0.1:${this.address().port}/foo?bar`;
55-
https.get(u);
56-
https.get(url.parse(u));
57-
https.get(new URL(u));
58-
});
52+
server.listen(0, common.mustCall(() => {
53+
const u = `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(new URL(u), common.mustCall(() => {
57+
server.close();
58+
}));
59+
}));
60+
}));
61+
}));

0 commit comments

Comments
 (0)