Skip to content

Commit

Permalink
fix(ext/node): fix timeout param validation in cp.execFile (denoland#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored Feb 5, 2024
1 parent 56f58a0 commit 961fa27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
17 changes: 17 additions & 0 deletions cli/tests/unit_node/child_process_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
10 changes: 1 addition & 9 deletions ext/node/polyfills/child_process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 961fa27

Please sign in to comment.