diff --git a/packages/core/src/services/shellExecutionService.test.ts b/packages/core/src/services/shellExecutionService.test.ts index 3bba16f9fa..f1aa08f41f 100644 --- a/packages/core/src/services/shellExecutionService.test.ts +++ b/packages/core/src/services/shellExecutionService.test.ts @@ -1390,6 +1390,7 @@ describe('ShellExecutionService child_process fallback', () => { cp.stdout?.emit('data', Buffer.from(chunk2)); cp.stdout?.emit('data', Buffer.from(chunk3)); cp.emit('exit', 0, null); + cp.emit('close', 0, null); }); const truncationMessage = @@ -1577,6 +1578,7 @@ describe('ShellExecutionService child_process fallback', () => { cp.stdout?.emit('data', binaryChunk1); cp.stdout?.emit('data', binaryChunk2); cp.emit('exit', 0, null); + cp.emit('close', 0, null); }); expect(onOutputEventMock).toHaveBeenCalledTimes(4); @@ -1641,6 +1643,7 @@ describe('ShellExecutionService child_process fallback', () => { mockPlatform.mockReturnValue('win32'); await simulateExecution('dir "foo bar"', (cp) => { cp.emit('exit', 0, null); + cp.emit('close', 0, null); }); expect(mockCpSpawn).toHaveBeenCalledWith( @@ -1658,6 +1661,7 @@ describe('ShellExecutionService child_process fallback', () => { mockPlatform.mockReturnValue('linux'); await simulateExecution('ls "foo bar"', (cp) => { cp.emit('exit', 0, null); + cp.emit('close', 0, null); }); expect(mockCpSpawn).toHaveBeenCalledWith( @@ -1772,6 +1776,7 @@ describe('ShellExecutionService execution method selection', () => { // Simulate exit to allow promise to resolve mockChildProcess.emit('exit', 0, null); + mockChildProcess.emit('close', 0, null); const result = await handle.result; expect(mockGetPty).not.toHaveBeenCalled(); @@ -1795,6 +1800,7 @@ describe('ShellExecutionService execution method selection', () => { // Simulate exit to allow promise to resolve mockChildProcess.emit('exit', 0, null); + mockChildProcess.emit('close', 0, null); const result = await handle.result; expect(mockGetPty).toHaveBeenCalled(); diff --git a/packages/core/src/services/shellExecutionService.ts b/packages/core/src/services/shellExecutionService.ts index 93c55f0636..5817ffd338 100644 --- a/packages/core/src/services/shellExecutionService.ts +++ b/packages/core/src/services/shellExecutionService.ts @@ -778,7 +778,7 @@ export class ShellExecutionService { abortSignal.addEventListener('abort', abortHandler, { once: true }); - child.on('exit', (code, signal) => { + child.on('close', (code, signal) => { handleExit(code, signal); });