* exec: clean up PTY resources on timeout and exit * cli: harden resume cleanup and watchdog stalled runs * cli: productionize PTY and resume reliability paths * docs: add PTY process supervision architecture plan * docs: rewrite PTY supervision plan as pre-rewrite baseline * docs: switch PTY supervision plan to one-go execution * docs: add one-line root cause to PTY supervision plan * docs: add OS contracts and test matrix to PTY supervision plan * docs: define process-supervisor package placement and scope * docs: tie supervisor plan to existing CI lanes * docs: place PTY supervisor plan under src/process * refactor(process): route exec and cli runs through supervisor * docs(process): refresh PTY supervision plan * wip * fix(process): harden supervisor timeout and PTY termination * fix(process): harden supervisor adapters env and wait handling * ci: avoid failing formal conformance on comment permissions * test(ui): fix cron request mock argument typing * fix(ui): remove leftover conflict marker * fix: supervise PTY processes (#14257) (openclaw#14257) (thanks @onutc)
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { afterEach, expect, test, vi } from "vitest";
|
|
import { listRunningSessions, resetProcessRegistryForTests } from "./bash-process-registry";
|
|
|
|
const { supervisorSpawnMock } = vi.hoisted(() => ({
|
|
supervisorSpawnMock: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("../process/supervisor/index.js", () => ({
|
|
getProcessSupervisor: () => ({
|
|
spawn: (...args: unknown[]) => supervisorSpawnMock(...args),
|
|
cancel: vi.fn(),
|
|
cancelScope: vi.fn(),
|
|
reconcileOrphans: vi.fn(),
|
|
getRecord: vi.fn(),
|
|
}),
|
|
}));
|
|
|
|
afterEach(() => {
|
|
resetProcessRegistryForTests();
|
|
vi.resetModules();
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
test("exec cleans session state when PTY fallback spawn also fails", async () => {
|
|
supervisorSpawnMock
|
|
.mockRejectedValueOnce(new Error("pty spawn failed"))
|
|
.mockRejectedValueOnce(new Error("child fallback failed"));
|
|
|
|
const { createExecTool } = await import("./bash-tools.exec");
|
|
const tool = createExecTool({ allowBackground: false });
|
|
|
|
await expect(
|
|
tool.execute("toolcall", {
|
|
command: "echo ok",
|
|
pty: true,
|
|
}),
|
|
).rejects.toThrow("child fallback failed");
|
|
|
|
expect(listRunningSessions()).toHaveLength(0);
|
|
});
|