Browse Source

lib: fix undefined timeout regression

63644dd1cd 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 <fedor@indutny.com>
Reviewed By: Evan Lucas <evanlucas@me.com>
v5.x
Ryan Graham 9 years ago
committed by Fedor Indutny
parent
commit
bde32f8a4d
  1. 2
      lib/timers.js
  2. 3
      test/parallel/test-timers-active.js

2
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();

3
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) {

Loading…
Cancel
Save