Skip to content

Commit 5e0a530

Browse files
committed
fix(agents): terminate ripgrep child on stdout/stderr stream errors
1 parent 50f7e4f commit 5e0a530

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/agents/sessions/tools/grep.stream-errors.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe("grep tool stream errors", () => {
4949
child.stdout.emit("error", new Error("stdout EPIPE"));
5050

5151
await expect(resultPromise).rejects.toThrow("stdout EPIPE");
52+
expect(child.killed).toBe(true);
5253
});
5354

5455
it("rejects when stderr emits an error", async () => {
@@ -68,5 +69,6 @@ describe("grep tool stream errors", () => {
6869
child.stderr.emit("error", new Error("stderr EPIPE"));
6970

7071
await expect(resultPromise).rejects.toThrow("stderr EPIPE");
72+
expect(child.killed).toBe(true);
7173
});
7274
});

src/agents/sessions/tools/grep.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,12 @@ export function createGrepToolDefinition(
267267
stderr = appendBoundedTextTail(stderr, chunk);
268268
});
269269
child.stdout?.on("error", (error) => {
270+
stopChild();
270271
cleanup();
271272
settle(() => reject(new Error(`ripgrep stdout error: ${error.message}`)));
272273
});
273274
child.stderr?.on("error", (error) => {
275+
stopChild();
274276
cleanup();
275277
settle(() => reject(new Error(`ripgrep stderr error: ${error.message}`)));
276278
});

0 commit comments

Comments
 (0)