fix(process): refuse malformed timeouts for stoppable commands
Since a stoppable command keeps its own deadline, execFile no longer validated its timeout. A negative, NaN, fractional or infinite value then started the command with no deadline (or one setTimeout coerced) instead of failing with ERR_OUT_OF_RANGE as execFile does. Apply execFile's unsigned-integer contract before spawning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c89b3a00dc
commit
59c91c88fe
@@ -123,6 +123,22 @@ describe.skipIf(process.platform === "win32")(
|
||||
expect(await readFile(stopped, "utf8")).toBe("SIGINT");
|
||||
});
|
||||
|
||||
it.each([-1, Number.NaN, 1.5, Number.POSITIVE_INFINITY])(
|
||||
"refuses a malformed timeout (%s) before starting the command, as execFile does",
|
||||
async (timeout) => {
|
||||
// Starting this command would fail with ENOENT instead.
|
||||
await expect(
|
||||
execFileOutput("/nonexistent/rea-command", [], {
|
||||
timeout,
|
||||
stopSignal: "SIGINT",
|
||||
}),
|
||||
).rejects.toMatchObject({ code: "ERR_OUT_OF_RANGE" });
|
||||
await expect(
|
||||
execFileOutput("/nonexistent/rea-command", [], { timeout }),
|
||||
).rejects.toMatchObject({ code: "ERR_OUT_OF_RANGE" });
|
||||
},
|
||||
);
|
||||
|
||||
it("kills a timed-out process that ignores the stop signal", async () => {
|
||||
const script = [
|
||||
'for (const name of ["SIGINT", "SIGTERM"]) process.on(name, () => {});',
|
||||
|
||||
Reference in New Issue
Block a user