fix(runner): close ACPX sidecar stdin cleanly

This commit is contained in:
Dotta 2026-09-02 18:45:12 -05:00
parent 16e165d958
commit 476ca3d877
2 changed files with 16 additions and 1 deletions

View File

@ -29,6 +29,21 @@ afterEach(async () => {
});
describe("qualified ACPX runtime sidecar", () => {
it("shuts down without using readline after stdin closes", async () => {
const sidecar = startSidecar();
sidecar.write(initializeRequest(1, "codex"));
await expect(
sidecar.next((frame) => frame.id === 1),
).resolves.toMatchObject({
id: 1,
ok: true,
});
await sidecar.close();
expect(sidecar.stderr()).not.toContain("ERR_USE_AFTER_CLOSE");
});
it("keeps session admission closed while any cleanup owner remains", () => {
const cleanup = Promise.resolve();

View File

@ -148,7 +148,7 @@ process.once("SIGINT", () => {
function requestShutdown(reason: string): void {
if (shutdownRequested) return;
shutdownRequested = true;
lines.pause();
if (!lines.closed) lines.pause();
pendingInput = enqueueAcpxSidecarInput(
pendingInput,
() => shutdown(reason),