mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-17 17:41:24 -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: {
|
||||
write: vi.fn(),
|
||||
end: vi.fn(),
|
||||
on: vi.fn(),
|
||||
} as unknown as Writable,
|
||||
stdout: {
|
||||
on: mockStdoutOn,
|
||||
|
||||
@@ -232,6 +232,12 @@ export class HookRunner {
|
||||
|
||||
// Send input to 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.end();
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ describe('HookSystem Integration', () => {
|
||||
stdin: {
|
||||
write: vi.fn(),
|
||||
end: vi.fn(),
|
||||
on: vi.fn(),
|
||||
} as unknown as Writable,
|
||||
stdout: {
|
||||
on: mockStdoutOn,
|
||||
|
||||
Reference in New Issue
Block a user