* fix(insights): await async sendMessage to prevent race condition (#613) The IPC handler for INSIGHTS_SEND_MESSAGE was declared async but never awaited the sendMessage() call. This caused race conditions where async environment setup (getAPIProfileEnv) wouldn't complete before the Python process was spawned. On Windows especially, this led to "Process exited with code 1" errors because environment variables weren't set in time. The fix adds await to ensure all async operations complete before returning, and wraps in try/catch to prevent unhandled rejections. Fixes #613 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: send errors to UI in catch block Address Gemini Code Assist feedback - errors caught in the try/catch block are now also sent to the renderer process via IPC_CHANNELS.INSIGHTS_ERROR. This ensures all error types (not just executor errors) are reported to the UI. Co-authored-by: gemini-code-assist[bot] <gemini-code-assist[bot]@users.noreply.github.com> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: add config.json to gitignore Prevents worktree configuration files from being accidentally committed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Alex <63423455+AlexMadera@users.noreply.github.com>
This commit is contained in:
@@ -51,6 +51,7 @@ lerna-debug.log*
|
||||
# Git Worktrees (parallel builds)
|
||||
# ===========================
|
||||
.worktrees/
|
||||
/config.json
|
||||
|
||||
# ===========================
|
||||
# Auto Claude Generated
|
||||
|
||||
@@ -42,9 +42,27 @@ export function registerInsightsHandlers(
|
||||
return;
|
||||
}
|
||||
|
||||
// Note: Python environment initialization should be handled by insightsService
|
||||
// or added here with proper dependency injection if needed
|
||||
insightsService.sendMessage(projectId, project.path, message, modelConfig);
|
||||
// Await the async sendMessage to ensure proper error handling and
|
||||
// that all async operations (like getProcessEnv) complete before
|
||||
// the handler returns. This fixes race conditions on Windows where
|
||||
// environment setup wouldn't complete before process spawn.
|
||||
try {
|
||||
await insightsService.sendMessage(projectId, project.path, message, modelConfig);
|
||||
} catch (error) {
|
||||
// Errors during sendMessage (executor errors) are already emitted via
|
||||
// the 'error' event, but we catch here to prevent unhandled rejection
|
||||
// and ensure all error types are reported to the UI
|
||||
console.error('[Insights IPC] Error in sendMessage:', error);
|
||||
const mainWindow = getMainWindow();
|
||||
if (mainWindow) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
mainWindow.webContents.send(
|
||||
IPC_CHANNELS.INSIGHTS_ERROR,
|
||||
projectId,
|
||||
`Failed to send message: ${errorMessage}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user