Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
timers: fix setTimeout expiration logic
Fix the timer logic to be the same as v10.30.0.

Fixes: #24203
  • Loading branch information
suguru03 committed Nov 16, 2018
commit 80dcd9f411c9c1d419cf21c22cb18e78b3b39b3d
2 changes: 1 addition & 1 deletion lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function listOnTimeout(list, now) {
// Check if this loop iteration is too early for the next timer.
// This happens if there are more timers scheduled for later in the list.
if (diff < msecs) {
list.expiry = timer._idleStart + msecs;
list.expiry = Math.max(timer._idleStart + msecs, now + 1);
list.id = timerListId++;
queue.percolateDown(1);
debug('%d list wait because diff is %d', msecs, diff);
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-timers-timeout-with-non-integer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';
const common = require('../common');

/**
* This test is for https://github.com/nodejs/node/issues/24203
*/
let count = 50;
const time = 1.00000000000001;
const exec = common.mustCall(() => {
if (--count === 0) {
return;
}
setTimeout(exec, time);
}, count);
exec();