1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

fix(ext/node): fix timeout param validation in cp.execFile (#22262)

This commit is contained in:
Yoshiya Hinosawa 2024-02-05 14:28:28 +09:00 committed by GitHub
parent 56f58a047e
commit 961fa27c76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 9 deletions

View file

@ -754,3 +754,20 @@ Deno.test(async function forkIpcKillDoesNotHang() {
await p.promise;
});
Deno.test(async function execFileWithUndefinedTimeout() {
const { promise, resolve, reject } = Promise.withResolvers<void>();
CP.execFile(
"git",
["-v"],
{ timeout: undefined, encoding: "utf8" },
(err) => {
if (err) {
reject(err);
return;
}
resolve();
},
);
await promise;
});

View file

@ -436,15 +436,7 @@ export function execFile(
shell: false,
...options,
};
if (!Number.isInteger(execOptions.timeout) || execOptions.timeout < 0) {
// In Node source, the first argument to error constructor is "timeout" instead of "options.timeout".
// timeout is indeed a member of options object.
throw new ERR_OUT_OF_RANGE(
"timeout",
"an unsigned integer",
execOptions.timeout,
);
}
validateTimeout(execOptions.timeout);
if (execOptions.maxBuffer < 0) {
throw new ERR_OUT_OF_RANGE(
"options.maxBuffer",