Skip to content

Commit

Permalink
lib: fix undefined timeout regression
Browse files Browse the repository at this point in the history
63644dd 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.
  • Loading branch information
rmg committed Oct 12, 2015
1 parent 47db247 commit 1e14233
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/timers.js
Expand Up @@ -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();

Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-timers-active.js
Expand Up @@ -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) {
Expand Down

0 comments on commit 1e14233

Please sign in to comment.