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.

PR-URL: #3331
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed By: Evan Lucas <[email protected]>
  • Loading branch information
rmg authored and jasnell committed Oct 13, 2015
1 parent b3cbd13 commit c245a19
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 c245a19

Please sign in to comment.