diff --git a/packages/core/src/tools/ripGrep.test.ts b/packages/core/src/tools/ripGrep.test.ts index e8eafc9b23..415db097e3 100644 --- a/packages/core/src/tools/ripGrep.test.ts +++ b/packages/core/src/tools/ripGrep.test.ts @@ -1009,10 +1009,10 @@ describe('RipGrepTool', () => { const result = await invocation.execute(controller.signal); expect(result.llmContent).toContain( - 'Error during grep search operation: ripgrep exited with code null', + 'Error during grep search operation: ripgrep was terminated by signal:', ); expect(result.returnDisplay).toContain( - 'Error: ripgrep exited with code null', + 'Error: ripgrep was terminated by signal:', ); }); }); diff --git a/packages/core/src/tools/ripGrep.ts b/packages/core/src/tools/ripGrep.ts index 0e52884b14..12f6d720e2 100644 --- a/packages/core/src/tools/ripGrep.ts +++ b/packages/core/src/tools/ripGrep.ts @@ -432,7 +432,7 @@ class GrepToolInvocation extends BaseToolInvocation< ); }); - child.on('close', (code) => { + child.on('close', (code, signal) => { options.signal.removeEventListener('abort', cleanup); const stdoutData = Buffer.concat(stdoutChunks).toString('utf8'); const stderrData = Buffer.concat(stderrChunks).toString('utf8'); @@ -442,9 +442,13 @@ class GrepToolInvocation extends BaseToolInvocation< } else if (code === 1) { resolve(''); // No matches found } else { - reject( - new Error(`ripgrep exited with code ${code}: ${stderrData}`), - ); + if (signal) { + reject(new Error(`ripgrep was terminated by signal: ${signal}`)); + } else { + reject( + new Error(`ripgrep exited with code ${code}: ${stderrData}`), + ); + } } }); });