mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 21:32:56 -07:00
fix(core): use close event instead of exit in child_process fallback (#25695)
Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
@@ -1390,6 +1390,7 @@ describe('ShellExecutionService child_process fallback', () => {
|
|||||||
cp.stdout?.emit('data', Buffer.from(chunk2));
|
cp.stdout?.emit('data', Buffer.from(chunk2));
|
||||||
cp.stdout?.emit('data', Buffer.from(chunk3));
|
cp.stdout?.emit('data', Buffer.from(chunk3));
|
||||||
cp.emit('exit', 0, null);
|
cp.emit('exit', 0, null);
|
||||||
|
cp.emit('close', 0, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
const truncationMessage =
|
const truncationMessage =
|
||||||
@@ -1577,6 +1578,7 @@ describe('ShellExecutionService child_process fallback', () => {
|
|||||||
cp.stdout?.emit('data', binaryChunk1);
|
cp.stdout?.emit('data', binaryChunk1);
|
||||||
cp.stdout?.emit('data', binaryChunk2);
|
cp.stdout?.emit('data', binaryChunk2);
|
||||||
cp.emit('exit', 0, null);
|
cp.emit('exit', 0, null);
|
||||||
|
cp.emit('close', 0, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(onOutputEventMock).toHaveBeenCalledTimes(4);
|
expect(onOutputEventMock).toHaveBeenCalledTimes(4);
|
||||||
@@ -1641,6 +1643,7 @@ describe('ShellExecutionService child_process fallback', () => {
|
|||||||
mockPlatform.mockReturnValue('win32');
|
mockPlatform.mockReturnValue('win32');
|
||||||
await simulateExecution('dir "foo bar"', (cp) => {
|
await simulateExecution('dir "foo bar"', (cp) => {
|
||||||
cp.emit('exit', 0, null);
|
cp.emit('exit', 0, null);
|
||||||
|
cp.emit('close', 0, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockCpSpawn).toHaveBeenCalledWith(
|
expect(mockCpSpawn).toHaveBeenCalledWith(
|
||||||
@@ -1658,6 +1661,7 @@ describe('ShellExecutionService child_process fallback', () => {
|
|||||||
mockPlatform.mockReturnValue('linux');
|
mockPlatform.mockReturnValue('linux');
|
||||||
await simulateExecution('ls "foo bar"', (cp) => {
|
await simulateExecution('ls "foo bar"', (cp) => {
|
||||||
cp.emit('exit', 0, null);
|
cp.emit('exit', 0, null);
|
||||||
|
cp.emit('close', 0, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockCpSpawn).toHaveBeenCalledWith(
|
expect(mockCpSpawn).toHaveBeenCalledWith(
|
||||||
@@ -1772,6 +1776,7 @@ describe('ShellExecutionService execution method selection', () => {
|
|||||||
|
|
||||||
// Simulate exit to allow promise to resolve
|
// Simulate exit to allow promise to resolve
|
||||||
mockChildProcess.emit('exit', 0, null);
|
mockChildProcess.emit('exit', 0, null);
|
||||||
|
mockChildProcess.emit('close', 0, null);
|
||||||
const result = await handle.result;
|
const result = await handle.result;
|
||||||
|
|
||||||
expect(mockGetPty).not.toHaveBeenCalled();
|
expect(mockGetPty).not.toHaveBeenCalled();
|
||||||
@@ -1795,6 +1800,7 @@ describe('ShellExecutionService execution method selection', () => {
|
|||||||
|
|
||||||
// Simulate exit to allow promise to resolve
|
// Simulate exit to allow promise to resolve
|
||||||
mockChildProcess.emit('exit', 0, null);
|
mockChildProcess.emit('exit', 0, null);
|
||||||
|
mockChildProcess.emit('close', 0, null);
|
||||||
const result = await handle.result;
|
const result = await handle.result;
|
||||||
|
|
||||||
expect(mockGetPty).toHaveBeenCalled();
|
expect(mockGetPty).toHaveBeenCalled();
|
||||||
|
|||||||
@@ -778,7 +778,7 @@ export class ShellExecutionService {
|
|||||||
|
|
||||||
abortSignal.addEventListener('abort', abortHandler, { once: true });
|
abortSignal.addEventListener('abort', abortHandler, { once: true });
|
||||||
|
|
||||||
child.on('exit', (code, signal) => {
|
child.on('close', (code, signal) => {
|
||||||
handleExit(code, signal);
|
handleExit(code, signal);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user