From e2c2b44d34eb4a235a57da5a5b4ef8c758806079 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. --- 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 0dc9ed80b7e577..50ae477d59d30f 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 9162406848d195..acddc2f41a45e8 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) {