Skip to content

Commit

Permalink
Throw an exception when timeout too large.
Browse files Browse the repository at this point in the history
closes #1644
  • Loading branch information
callumacrae authored and boneskull committed Jul 1, 2016
1 parent 194a136 commit 0e7f38f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/runnable.js
Expand Up @@ -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') {
Expand Down
7 changes: 7 additions & 0 deletions test/runnable.js
Expand Up @@ -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;
Expand Down

0 comments on commit 0e7f38f

Please sign in to comment.