Skip to content

Commit 13529be

Browse files
committed
test: fix test-timers-unrefd-interval-still-fires
Remove arbitrary timeout duration. This is a functionality test and not a performance benchmark. Rely on test runner timeout. Confirmed that the test (with ES6-isms removed) hangs/times out in Node 0.10.34 (which has the bug that this test is supposed to catch) and passes in 0.10.35 (which has the fix). So that is good. Fixes: #4559
1 parent e071894 commit 13529be

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

test/parallel/test-timers-unrefd-interval-still-fires.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
'use strict';
22
/*
33
* This test is a regression test for joyent/node#8900.
4+
*
5+
* Node.js 0.10.34 contains the bug that this test detects.
6+
* Node.js 0.10.35 contains the fix.
7+
*
8+
* Due to the introduction of ES6-isms, comment out `'use strict'` and
9+
* `require('../common');` to run the test on Node.js 0.10.x.
410
*/
5-
const common = require('../common');
11+
require('../common');
612

7-
const TEST_DURATION = common.platformTimeout(100);
813
const N = 3;
914
var nbIntervalFired = 0;
1015

11-
const keepOpen = setTimeout(() => {
12-
console.error('[FAIL] Interval fired %d/%d times.', nbIntervalFired, N);
13-
throw new Error('Test timed out. keepOpen was not canceled.');
14-
}, TEST_DURATION);
16+
const keepOpen = setInterval(function() {}, 9999);
1517

16-
const timer = setInterval(() => {
18+
const timer = setInterval(function() {
1719
++nbIntervalFired;
1820
if (nbIntervalFired === N) {
1921
clearInterval(timer);
20-
timer._onTimeout = () => {
21-
throw new Error('Unrefd interval fired after being cleared.');
22-
};
23-
clearTimeout(keepOpen);
22+
clearInterval(keepOpen);
2423
}
2524
}, 1);
2625

0 commit comments

Comments
 (0)