diff --git a/lib/kill.js b/lib/kill.js index a684e2c043..7f6f8dd7f2 100644 --- a/lib/kill.js +++ b/lib/kill.js @@ -44,7 +44,7 @@ const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => { return DEFAULT_FORCE_KILL_TIMEOUT; } - if (!Number.isInteger(forceKillAfterTimeout) || forceKillAfterTimeout < 0) { + if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) { throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`); } @@ -71,7 +71,7 @@ const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise return spawnedPromise; } - if (!Number.isInteger(timeout) || timeout < 0) { + if (!Number.isFinite(timeout) || timeout < 0) { throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`); } diff --git a/test/kill.js b/test/kill.js index b402c42d12..6ca54a4a56 100644 --- a/test/kill.js +++ b/test/kill.js @@ -61,9 +61,9 @@ if (process.platform !== 'win32') { t.is(signal, 'SIGKILL'); }); - test('`forceKillAfterTimeout` should not be a float', t => { + test('`forceKillAfterTimeout` should not be NaN', t => { t.throws(() => { - execa('noop').kill('SIGTERM', {forceKillAfterTimeout: 0.5}); + execa('noop').kill('SIGTERM', {forceKillAfterTimeout: NaN}); }, {instanceOf: TypeError, message: /non-negative integer/}); });