Skip to content

Commit 60704fb

Browse files
TrottMylesBorins
authored andcommitted
test: fix flaky test-timers-blocking-callback
This test was failing on FreeBSD from time to time in the project CI. The bug the test was written for would guarantee that the timer would fire at least 100ms late, but the assertion was firing if it was more than 50ms late. This changes the assertion to fire when the timer is more than 100ms late. I ran a modified version of this test using 0.10.38 (which has the bug) and 0.10.39 (which has the fix) to confirm that it still fails in the buggy one and passes in the fixed one. PR-URL: #9198 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Julien Gilli <[email protected]>
1 parent 96e8e86 commit 60704fb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/parallel/test-timers-blocking-callback.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
*
1010
* The reason was that the value that represents the current time was not
1111
* updated between the time the original callback was called and the time
12-
* the added timer was processed by timers.listOnTimeout. That lead the
12+
* the added timer was processed by timers.listOnTimeout. That led the
1313
* logic in timers.listOnTimeout to do an incorrect computation that made
1414
* the added timer fire with a timeout of scheduledTimeout +
1515
* timeSpentInCallback.
1616
*
1717
* This test makes sure that a timer added by another timer's callback
18-
* fire with the expected timeout.
18+
* fires with the expected timeout.
1919
*
2020
* It makes sure that it works when the timers list for a given timeout is
2121
* empty (see testAddingTimerToEmptyTimersList) and when the timers list
@@ -44,12 +44,11 @@ function blockingCallback(callback) {
4444
if (nbBlockingCallbackCalls > 1) {
4545
latestDelay = Timer.now() - timeCallbackScheduled;
4646
// Even if timers can fire later than when they've been scheduled
47-
// to fire, they should more than 50% later with a timeout of
48-
// 100ms. Firing later than that would mean that we hit the regression
49-
// highlighted in
47+
// to fire, they shouldn't generally be more than 100% late in this case.
48+
// But they are guaranteed to be at least 100ms late given the bug in
5049
// https://github.com/nodejs/node-v0.x-archive/issues/15447 and
5150
// https://github.com/nodejs/node-v0.x-archive/issues/9333..
52-
assert(latestDelay < TIMEOUT * 1.5);
51+
assert(latestDelay < TIMEOUT * 2);
5352
if (callback)
5453
return callback();
5554
} else {

0 commit comments

Comments
 (0)