Skip to content

Commit 485a2db

Browse files
committed
test: use localhost test instead of connecting to remote
Fixes: #39008
1 parent d615aeb commit 485a2db

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

test/parallel/test-https-agent-unref-socket.js

Lines changed: 20 additions & 4 deletions
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 net = require('net');
17+
const server = net.createServer();
18+
server.listen(0);
19+
server.on('listening', () => {
20+
const port = server.address().port;
21+
const { fork } = require('child_process');
22+
const child = fork(__filename, ['localhost', port], {});
23+
child.on('close', (exit_code) => {
24+
server.close();
25+
if (exit_code == null || exit_code !== 0)
26+
process.exit(1);
27+
});
28+
});
29+
}

0 commit comments

Comments
 (0)