test: fix flaky unrefed timers test
authorRich Trott <rtrott@gmail.com>
Sat, 9 Jan 2016 05:17:53 +0000 (21:17 -0800)
committerMyles Borins <mborins@us.ibm.com>
Mon, 15 Feb 2016 19:30:23 +0000 (11:30 -0800)
Remove unnecessary `setImmediate()` that causes a minor race condition.
Stop the test after 3 occurrences rather than 5 to allow for slower
hosts running the test in parallel with other tests.

Fixes: https://github.com/nodejs/node/issues/4559
PR-URL: https://github.com/nodejs/node/pull/4599
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
test/parallel/test-timers-unrefd-interval-still-fires.js

index 8f26d28816b60c5f76c89d38834ed86eff41ad2f..172da8bb954fa79646d006f5763929b601d7ce29 100644 (file)
@@ -5,7 +5,7 @@
 const common = require('../common');
 
 const TEST_DURATION = common.platformTimeout(100);
-const N = 5;
+const N = 3;
 var nbIntervalFired = 0;
 
 const keepOpen = setTimeout(() => {
@@ -20,7 +20,7 @@ const timer = setInterval(() => {
     timer._onTimeout = () => {
       throw new Error('Unrefd interval fired after being cleared.');
     };
-    setImmediate(() => clearTimeout(keepOpen));
+    clearTimeout(keepOpen);
   }
 }, 1);