summaryrefslogtreecommitdiff
path: root/test/internet/test-net-connect-unref.js
blob: ad24683b34d49ed654a7e42207cbd78b96ebf154 (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
'use strict';
require('../common');
var assert = require('assert');
var net = require('net');

var client, killed = false, ended = false;
var TIMEOUT = 10 * 1000;

client = net.createConnection(53, '8.8.8.8', function() {
  client.unref();
});

client.on('close', function() {
  ended = true;
});

setTimeout(function() {
  killed = true;
  client.end();
}, TIMEOUT).unref();

process.on('exit', function() {
  assert.strictEqual(killed, false, 'A client should have connected');
  assert.strictEqual(ended, false, 'A client should stay connected');
});