mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-15 13:20:49 +00:00
perf: reduce gateway startup overhead
This commit is contained in:
@@ -59,6 +59,23 @@ describe("gateway --force helpers", () => {
|
||||
expect(listPortListeners(18789)).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not re-scan lsof when no listeners were killed", async () => {
|
||||
(execFileSync as unknown as Mock).mockImplementation(() => {
|
||||
const err = new Error("no matches") as NodeJS.ErrnoException & { status?: number };
|
||||
err.status = 1; // lsof uses exit 1 for no matches
|
||||
throw err;
|
||||
});
|
||||
|
||||
const result = await forceFreePortAndWait(18789, { timeoutMs: 500, intervalMs: 100 });
|
||||
|
||||
expect(result).toEqual({
|
||||
killed: [],
|
||||
waitedMs: 0,
|
||||
escalatedToSigkill: false,
|
||||
});
|
||||
expect(execFileSync).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("throws when lsof missing", () => {
|
||||
(execFileSync as unknown as Mock).mockImplementation(() => {
|
||||
const err = new Error("not found") as NodeJS.ErrnoException;
|
||||
|
||||
Reference in New Issue
Block a user