Skip to content

Commit df17c62

Browse files
AdamMajertargos
authored andcommitted
test: use localhost test instead of connecting to remote
Fixes: #39008 PR-URL: #39011 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Zijian Liu <[email protected]>
1 parent 35331cb commit df17c62

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Diff for: test/parallel/test-https-agent-unref-socket.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@ if (!common.hasCrypto)
66

77
const https = require('https');
88

9-
const request = https.get('https://example.com');
9+
if (process.argv[2] === 'localhost') {
10+
const request = https.get('https://localhost:' + process.argv[3]);
1011

11-
request.on('socket', (socket) => {
12-
socket.unref();
13-
});
12+
request.on('socket', (socket) => {
13+
socket.unref();
14+
});
15+
} else {
16+
const assert = require('assert');
17+
const net = require('net');
18+
const server = net.createServer();
19+
server.listen(0);
20+
server.on('listening', () => {
21+
const port = server.address().port;
22+
const { fork } = require('child_process');
23+
const child = fork(__filename, ['localhost', port], {});
24+
child.on('close', (exit_code) => {
25+
server.close();
26+
assert.strictEqual(exit_code, 0);
27+
});
28+
});
29+
}

0 commit comments

Comments
 (0)