mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-22 18:01:16 +00:00
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:
@@ -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 () => {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user