mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
fix(core): handle EPIPE error in hook runner when writing to stdin (#14231)
This commit is contained in:
@@ -64,6 +64,7 @@ describe('HookRunner', () => {
|
|||||||
stdin: {
|
stdin: {
|
||||||
write: vi.fn(),
|
write: vi.fn(),
|
||||||
end: vi.fn(),
|
end: vi.fn(),
|
||||||
|
on: vi.fn(),
|
||||||
} as unknown as Writable,
|
} as unknown as Writable,
|
||||||
stdout: {
|
stdout: {
|
||||||
on: mockStdoutOn,
|
on: mockStdoutOn,
|
||||||
|
|||||||
@@ -232,6 +232,12 @@ export class HookRunner {
|
|||||||
|
|
||||||
// Send input to stdin
|
// Send input to stdin
|
||||||
if (child.stdin) {
|
if (child.stdin) {
|
||||||
|
child.stdin.on('error', (err: NodeJS.ErrnoException) => {
|
||||||
|
// Ignore EPIPE errors which happen when the child process closes stdin early
|
||||||
|
if (err.code !== 'EPIPE') {
|
||||||
|
debugLogger.warn(`Hook stdin error: ${err}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
child.stdin.write(JSON.stringify(input));
|
child.stdin.write(JSON.stringify(input));
|
||||||
child.stdin.end();
|
child.stdin.end();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ describe('HookSystem Integration', () => {
|
|||||||
stdin: {
|
stdin: {
|
||||||
write: vi.fn(),
|
write: vi.fn(),
|
||||||
end: vi.fn(),
|
end: vi.fn(),
|
||||||
|
on: vi.fn(),
|
||||||
} as unknown as Writable,
|
} as unknown as Writable,
|
||||||
stdout: {
|
stdout: {
|
||||||
on: mockStdoutOn,
|
on: mockStdoutOn,
|
||||||
|
|||||||
Reference in New Issue
Block a user