node/test/parallel/test-https-agent-unref-socket.js
Antoine du Hamel d539d6e99f
test: ensure assertions are reached on more tests
PR-URL: https://github.com/nodejs/node/pull/60759
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2025-11-24 22:36:53 +00:00

30 lines
778 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const https = require('https');
if (process.argv[2] === 'localhost') {
const request = https.get('https://localhost:' + process.argv[3]);
request.on('socket', (socket) => {
socket.unref();
});
} else {
const assert = require('assert');
const net = require('net');
const server = net.createServer();
server.listen(0);
server.on('listening', common.mustCall(() => {
const port = server.address().port;
const { fork } = require('child_process');
const child = fork(__filename, ['localhost', port], {});
child.on('close', common.mustCall((exit_code) => {
server.close();
assert.strictEqual(exit_code, 0);
}));
}));
}