mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
fix(ext/node): fix timeout param validation in cp.execFile (#22262)
This commit is contained in:
parent
56f58a047e
commit
961fa27c76
2 changed files with 18 additions and 9 deletions
|
@ -754,3 +754,20 @@ Deno.test(async function forkIpcKillDoesNotHang() {
|
||||||
|
|
||||||
await p.promise;
|
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;
|
||||||
|
});
|
||||||
|
|
|
@ -436,15 +436,7 @@ export function execFile(
|
||||||
shell: false,
|
shell: false,
|
||||||
...options,
|
...options,
|
||||||
};
|
};
|
||||||
if (!Number.isInteger(execOptions.timeout) || execOptions.timeout < 0) {
|
validateTimeout(execOptions.timeout);
|
||||||
// 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,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (execOptions.maxBuffer < 0) {
|
if (execOptions.maxBuffer < 0) {
|
||||||
throw new ERR_OUT_OF_RANGE(
|
throw new ERR_OUT_OF_RANGE(
|
||||||
"options.maxBuffer",
|
"options.maxBuffer",
|
||||||
|
|
Loading…
Reference in a new issue