Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/adapters/process-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ async function terminatePosix(
pid: number,
graceMs: number,
): Promise<TerminationScope> {
if (hasEnded(child)) {
return TERMINATION_SCOPE.DIRECT_CHILD_ONLY;
}

let groupReached = signalProcessGroup(pid, 'SIGTERM');
if (!groupReached) {
killDirectChild(child, 'SIGTERM');
Expand Down Expand Up @@ -743,9 +747,19 @@ export function invokeAgentProcess(
};

if (child.stdout !== null) {
onEvent(child.stdout, 'error', () => {
// Read failures are consumed here without promoting the exchange to a
// terminal failure state, matching the stdin pattern. The close path
// decides the outcome.
});
onReadableData(child.stdout, onStdout);
}
if (child.stderr !== null) {
onEvent(child.stderr, 'error', () => {
// Read failures are consumed here without promoting the exchange to a
// terminal failure state, matching the stdin pattern. The close path
// decides the outcome.
});
onReadableData(child.stderr, onStderr);
}

Expand Down
12 changes: 11 additions & 1 deletion tests/adapters/process-transport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
}
});

it('accepts a zero-argument argv', async () => {
it('accepts a single-argument argv', async () => {
const exchange = await invokeAgentProcess(
makeSpec({ args: ['--version'] }),
makeLimits(),
Expand All @@ -127,6 +127,16 @@
expect(exchange.exitCode).toBe(0);
});

it('accepts a zero-argument argv', async () => {
const exchange = await invokeAgentProcess(
makeSpec({ args: [] }),
makeLimits({ timeoutMs: 500, graceMs: 200 }),
);

// Node starts an interactive REPL with no arguments, which times out
expect(exchange.outcome).toBe('TIMED_OUT');

Check failure on line 137 in tests/adapters/process-transport.test.ts

View workflow job for this annotation

GitHub Actions / verify

tests/adapters/process-transport.test.ts > invokeAgentProcess — success > accepts a zero-argument argv

AssertionError: expected 'EXITED' to be 'TIMED_OUT' // Object.is equality Expected: "TIMED_OUT" Received: "EXITED" ❯ tests/adapters/process-transport.test.ts:137:30
}, 15_000);

it('reports source bytes that match the decoded stdout for valid UTF-8', async () => {
const exchange = await runStub(STUB.MULTIBYTE, ['3']);

Expand Down
Loading