From 6bcf07112007c4ea9f7942e708a17ef5caae4df4 Mon Sep 17 00:00:00 2001
From: Alix-007
Date: Fri, 17 Jul 2026 02:36:07 +0800
Subject: [PATCH] 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
* test(infra): cover process probe timeout
---------
Co-authored-by: Peter Steinberger
---
src/shared/pid-alive.test.ts | 8 ++++++--
src/shared/pid-alive.ts | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/shared/pid-alive.test.ts b/src/shared/pid-alive.test.ts
index 6f1cde0634eb..9f744f71f5a2 100644
--- a/src/shared/pid-alive.test.ts
+++ b/src/shared/pid-alive.test.ts
@@ -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 () => {
diff --git a/src/shared/pid-alive.ts b/src/shared/pid-alive.ts
index 60fc26187150..b36955e25dfc 100644
--- a/src/shared/pid-alive.ts
+++ b/src/shared/pid-alive.ts
@@ -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