From bde32f8a4d24cf5201b3178c275b1cda9d77003c Mon Sep 17 00:00:00 2001 From: Ryan Graham Date: Mon, 12 Oct 2015 16:03:59 -0700 Subject: [PATCH] lib: fix undefined timeout regression 63644dd1cd6e introduced a regression caused by everyone's favourite JavaScript feature: undefined < 0 === undefined >= 0. Add a case to the existing tests to cover this scenario and then add the check for undefined that makes the test pass. PR-URL: https://github.com/nodejs/node/pull/3331 Reviewed-By: Fedor Indutny Reviewed By: Evan Lucas --- lib/timers.js | 2 +- test/parallel/test-timers-active.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/timers.js b/lib/timers.js index 0dc9ed80b7..50ae477d59 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -30,7 +30,7 @@ var lists = {}; // with them. exports.active = function(item) { const msecs = item._idleTimeout; - if (msecs < 0) return; + if (msecs < 0 || msecs === undefined) return; item._idleStart = Timer.now(); diff --git a/test/parallel/test-timers-active.js b/test/parallel/test-timers-active.js index 9162406848..acddc2f41a 100644 --- a/test/parallel/test-timers-active.js +++ b/test/parallel/test-timers-active.js @@ -22,7 +22,8 @@ legitTimers.forEach(function(legit) { // active() should not create a timer for these var bogusTimers = [ - { _idleTimeout: -1 } + { _idleTimeout: -1 }, + { _idleTimeout: undefined }, ]; bogusTimers.forEach(function(bogus) {