Skip to content

Commit 9a157b3

Browse files
Kikobeatssindresorhusehmicky
authoredJul 6, 2020
Fix use of floating number for the timeout and forceKillAfterTimeout options (#431)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com> Co-authored-by: ehmicky <ehmicky@users.noreply.github.com>
1 parent a827d82 commit 9a157b3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎lib/kill.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
4444
return DEFAULT_FORCE_KILL_TIMEOUT;
4545
}
4646

47-
if (!Number.isInteger(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
47+
if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
4848
throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
4949
}
5050

@@ -71,7 +71,7 @@ const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise
7171
return spawnedPromise;
7272
}
7373

74-
if (!Number.isInteger(timeout) || timeout < 0) {
74+
if (!Number.isFinite(timeout) || timeout < 0) {
7575
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
7676
}
7777

‎test/kill.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ if (process.platform !== 'win32') {
6161
t.is(signal, 'SIGKILL');
6262
});
6363

64-
test('`forceKillAfterTimeout` should not be a float', t => {
64+
test('`forceKillAfterTimeout` should not be NaN', t => {
6565
t.throws(() => {
66-
execa('noop').kill('SIGTERM', {forceKillAfterTimeout: 0.5});
66+
execa('noop').kill('SIGTERM', {forceKillAfterTimeout: NaN});
6767
}, {instanceOf: TypeError, message: /non-negative integer/});
6868
});
6969

0 commit comments

Comments
 (0)
Please sign in to comment.