summaryrefslogtreecommitdiff
path: root/test/parallel/test-https-agent-unref-socket.js
blob: 49169b523e10424a61cb354d5e6e4e5fe36746c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'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', () => {
    const port = server.address().port;
    const { fork } = require('child_process');
    const child = fork(__filename, ['localhost', port], {});
    child.on('close', (exit_code) => {
      server.close();
      assert.strictEqual(exit_code, 0);
    });
  });
}