node/test/parallel/test-timers-unrefd-interval-still-fires.js
Jeremiah Senkpiel 65cd2a0f96 test: increase timeouts on some unref timers tests
Fix: https://github.com/nodejs/node/issues/5351
Refs: https://github.com/nodejs/node/pull/4561
PR-URL: https://github.com/nodejs/node/pull/5352

Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
2016-02-22 12:14:58 -05:00

28 lines
676 B
JavaScript

'use strict';
/*
* This test is a regression test for joyent/node#8900.
*/
const common = require('../common');
const TEST_DURATION = common.platformTimeout(1000);
const N = 3;
var nbIntervalFired = 0;
const keepOpen = setTimeout(() => {
console.error('[FAIL] Interval fired %d/%d times.', nbIntervalFired, N);
throw new Error('Test timed out. keepOpen was not canceled.');
}, TEST_DURATION);
const timer = setInterval(() => {
++nbIntervalFired;
if (nbIntervalFired === N) {
clearInterval(timer);
timer._onTimeout = () => {
throw new Error('Unrefd interval fired after being cleared.');
};
clearTimeout(keepOpen);
}
}, 1);
timer.unref();