diff --git a/server/src/adapters/process/execute.test.ts b/server/src/adapters/process/execute.test.ts new file mode 100644 index 0000000000..8f26bcf694 --- /dev/null +++ b/server/src/adapters/process/execute.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, it, vi } from "vitest"; + +const mocks = vi.hoisted(() => ({ + runChildProcess: vi.fn(), +})); + +vi.mock("../utils.js", async (importOriginal) => ({ + ...(await importOriginal()), + runChildProcess: mocks.runChildProcess, +})); + +import { execute } from "./execute.js"; + +describe("process adapter execution", () => { + it("fails when a child is terminated by a signal with no exit code", async () => { + mocks.runChildProcess.mockResolvedValueOnce({ + exitCode: null, + signal: "SIGTERM", + timedOut: false, + stdout: "", + stderr: "", + }); + + const result = await execute({ + runId: "signal-test", + agent: { id: "agent", companyId: "company" }, + config: { command: process.execPath }, + onLog: async () => {}, + onMeta: async () => {}, + } as any); + + expect(result).toMatchObject({ + exitCode: null, + signal: "SIGTERM", + timedOut: false, + }); + expect(result.errorMessage).toContain("SIGTERM"); + expect(result.resultJson).toEqual({ stdout: "", stderr: "" }); + }); +}); diff --git a/server/src/adapters/process/execute.ts b/server/src/adapters/process/execute.ts index 16ef40457e..8ce52c3f2e 100644 --- a/server/src/adapters/process/execute.ts +++ b/server/src/adapters/process/execute.ts @@ -80,6 +80,19 @@ export async function execute(ctx: AdapterExecutionContext): Promise