summaryrefslogtreecommitdiff
path: root/test/parallel/test-timers-unrefd-interval-still-fires.js
blob: 45c59c01082777d1f66955a711aa06fce0179f2d (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
'use strict';
/*
 * This test is a regression test for joyent/node#8900.
 */
const common = require('../common');

const TEST_DURATION = common.platformTimeout(1000);
let N = 3;

const keepOpen =
  setTimeout(
    common.mustNotCall('Test timed out. keepOpen was not canceled.'),
    TEST_DURATION);

const timer = setInterval(common.mustCall(() => {
  if (--N === 0) {
    clearInterval(timer);
    timer._onTimeout =
      common.mustNotCall('Unrefd interval fired after being cleared');
    clearTimeout(keepOpen);
  }
}, N), 1);

timer.unref();