Skip to content

Commit

Permalink
fix(lib/runnable.js): Fix timeout upper limit check (again)
Browse files Browse the repository at this point in the history
Seems PR mochajs#1652 upper limit check was off by one. Fixed it and documentation.
  • Loading branch information
plroebuck committed Nov 6, 2018
1 parent 96f5c18 commit 72f60d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/runnable.js
Expand Up @@ -61,7 +61,7 @@ utils.inherits(Runnable, EventEmitter);
*
* @description
* A string argument can use shorthand (such as "2s") and will be converted.
* If the value is `0` or exceeds `2^<sup>31</sup>`, timeouts will be disabled.
* If value is `0` or exceeds `2^<sup>31</sup>-1`, timeouts will be disabled.
*
* @private
* @param {number|string} ms - Timeout threshold value.
Expand All @@ -76,7 +76,7 @@ Runnable.prototype.timeout = function(ms) {
ms = milliseconds(ms);
}
// see #1652 for reasoning
if (ms === 0 || ms > Math.pow(2, 31)) {
if (ms === 0 || ms > Math.pow(2, 31) - 1) {
this._enableTimeouts = false;
}
debug('timeout %d', ms);
Expand Down

0 comments on commit 72f60d9

Please sign in to comment.