Skip to content

Commit 0e7f38f

Browse files
callumacraeboneskull
authored andcommitted
Throw an exception when timeout too large.
closes #1644
1 parent 194a136 commit 0e7f38f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/runnable.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ Runnable.prototype.timeout = function(ms) {
7474
if (!arguments.length) {
7575
return this._timeout;
7676
}
77-
if (ms === 0) {
77+
// see #1652 for reasoning
78+
if (ms === 0 || ms > Math.pow(2, 31)) {
7879
this._enableTimeouts = false;
7980
}
8081
if (typeof ms === 'string') {

test/runnable.js

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ describe('Runnable(title, fn)', function(){
4141
})
4242
})
4343

44+
describe('#timeout(ms) when ms>2^31', function(){
45+
it('should throw an error', function () {
46+
var run = new Runnable;
47+
run.timeout.bind(run, 1e10).should.throw(/Timeout too large/);
48+
});
49+
});
50+
4451
describe('#enableTimeouts(enabled)', function(){
4552
it('should set enabled', function(){
4653
var run = new Runnable;

0 commit comments

Comments
 (0)