fix(infra): bound macOS process start probes (#109064)

* fix(infra): bound macOS process start probes

* docs(changelog): note macOS process probe deadline

Co-authored-by: Alix-007 <li.long15@xydigit.com>

* test(infra): cover process probe timeout

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
Alix-007
2026-07-17 02:36:07 +08:00
committed by GitHub
parent 6175e6a98c
commit 6bcf071120
2 changed files with 9 additions and 2 deletions

View File

@@ -165,14 +165,18 @@ describe("process start times", () => {
expect.objectContaining({
encoding: "utf8",
env: expect.objectContaining({ LC_ALL: "C", TZ: "UTC" }),
timeout: 1000,
}),
);
});
});
it("returns null for unavailable Darwin file-lock start times", () => {
it("fails conservatively when the Darwin file-lock start-time probe times out", () => {
vi.spyOn(childProcess, "execFileSync").mockImplementation(() => {
throw new Error("missing process");
throw Object.assign(new Error("spawnSync /bin/ps ETIMEDOUT"), {
code: "ETIMEDOUT",
signal: "SIGTERM",
});
});
return withMockedPlatform("darwin", async () => {

View File

@@ -2,6 +2,8 @@
import childProcess from "node:child_process";
import fsSync from "node:fs";
const DARWIN_PS_TIMEOUT_MS = 1000;
function isValidPid(pid: number): boolean {
return Number.isInteger(pid) && pid > 0;
}
@@ -59,6 +61,7 @@ function getDarwinProcessStartTime(pid: number): number | null {
encoding: "utf8",
env: { ...process.env, LC_ALL: "C", TZ: "UTC" },
stdio: ["ignore", "pipe", "ignore"],
timeout: DARWIN_PS_TIMEOUT_MS,
})
.trim();
// Darwin's lstart output has no timezone. Force UTC for both ps and parsing so