summaryrefslogtreecommitdiff
path: root/test/parallel/test-timers-unref-leak.js
blob: a1b1265763bf1db191cff8071c731a2df5b9df1e (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
'use strict';
require('../common');
var assert = require('assert');

var called = 0;
var closed = 0;

var timeout = setTimeout(function() {
  called++;
}, 10);
timeout.unref();

// Wrap `close` method to check if the handle was closed
var close = timeout._handle.close;
timeout._handle.close = function() {
  closed++;
  return close.apply(this, arguments);
};

// Just to keep process alive and let previous timer's handle die
setTimeout(function() {
}, 50);

process.on('exit', function() {
  assert.equal(called, 1);
  assert.equal(closed, 1);
});