diff --git a/lib/runnable.js b/lib/runnable.js index c7d210d5b2..7ccb4e3ffc 100644 --- a/lib/runnable.js +++ b/lib/runnable.js @@ -74,7 +74,8 @@ Runnable.prototype.timeout = function(ms) { if (!arguments.length) { return this._timeout; } - if (ms === 0) { + // see #1652 for reasoning + if (ms === 0 || ms > Math.pow(2, 31)) { this._enableTimeouts = false; } if (typeof ms === 'string') { diff --git a/test/runnable.js b/test/runnable.js index a3d88adda2..ba1ea48f55 100644 --- a/test/runnable.js +++ b/test/runnable.js @@ -41,6 +41,13 @@ describe('Runnable(title, fn)', function(){ }) }) + describe('#timeout(ms) when ms>2^31', function(){ + it('should throw an error', function () { + var run = new Runnable; + run.timeout.bind(run, 1e10).should.throw(/Timeout too large/); + }); + }); + describe('#enableTimeouts(enabled)', function(){ it('should set enabled', function(){ var run = new Runnable;