Skip to content

Commit 5d2b348

Browse files
committed
set max options.timaout accepted value to TIMEOUT_MAX
1 parent 17ede2d commit 5d2b348

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/internal/test_runner/test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ class Test extends AsyncResource {
140140
}
141141

142142
if (timeout != null && timeout !== Infinity) {
143-
validateNumber(timeout, 'options.timeout', 0);
144-
if (timeout < TIMEOUT_MAX) {
145-
this.timeout = timeout;
146-
}
143+
validateNumber(timeout, 'options.timeout', 0, TIMEOUT_MAX);
144+
this.timeout = timeout;
147145
}
148146

149147
if (testOnlyFlag && !this.only) {

test/parallel/test-runner-option-validation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const test = require('node:test');
66
[Symbol(), {}, [], () => {}, 1n, true, '1'].forEach((timeout) => {
77
assert.throws(() => test({ timeout }), { code: 'ERR_INVALID_ARG_TYPE' });
88
});
9-
[-1, -Infinity, NaN].forEach((timeout) => {
9+
[-1, -Infinity, NaN, 2 ** 33, Number.MAX_SAFE_INTEGER].forEach((timeout) => {
1010
assert.throws(() => test({ timeout }), { code: 'ERR_OUT_OF_RANGE' });
1111
});
12-
[null, undefined, Infinity, 0, 1, 1.1, 2 ** 33].forEach((timeout) => {
12+
[null, undefined, Infinity, 0, 1, 1.1].forEach((timeout) => {
1313
// Valid values should not throw.
1414
test({ timeout });
1515
});

0 commit comments

Comments
 (0)