fix: stop search failures from hanging on Brainstorming#1054
Open
stablegenius49 wants to merge 1 commit intoItzCrazyKns:masterfrom
Open
fix: stop search failures from hanging on Brainstorming#1054stablegenius49 wants to merge 1 commit intoItzCrazyKns:masterfrom
stablegenius49 wants to merge 1 commit intoItzCrazyKns:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/agents/search/api.ts">
<violation number="1" location="src/lib/agents/search/api.ts:103">
P2: Raw exception messages are emitted to client-facing session error events, exposing internal error details.</violation>
</file>
<file name="src/lib/agents/search/index.ts">
<violation number="1" location="src/lib/agents/search/index.ts:186">
P1: Emitting `session.emit('error', ...)` in catch can throw synchronously and prevent persisting `status: 'error'`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Comment on lines
+186
to
+188
| session.emit('error', { | ||
| data: error instanceof Error ? error.message : 'Search failed', | ||
| }); |
Contributor
There was a problem hiding this comment.
P1: Emitting session.emit('error', ...) in catch can throw synchronously and prevent persisting status: 'error'.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/agents/search/index.ts, line 186:
<comment>Emitting `session.emit('error', ...)` in catch can throw synchronously and prevent persisting `status: 'error'`.</comment>
<file context>
@@ -11,175 +11,200 @@ import { TextBlock } from '@/lib/types';
+ .execute();
+ } catch (error) {
+ console.error('Error while running search:', error);
+ session.emit('error', {
+ data: error instanceof Error ? error.message : 'Search failed',
+ });
</file context>
Suggested change
| session.emit('error', { | |
| data: error instanceof Error ? error.message : 'Search failed', | |
| }); | |
| try { | |
| session.emit('error', { | |
| data: error instanceof Error ? error.message : 'Search failed', | |
| }); | |
| } catch (emitError) { | |
| console.error('Failed to emit session error event:', emitError); | |
| } |
| } catch (error) { | ||
| console.error('Error while running API search:', error); | ||
| session.emit('error', { | ||
| data: error instanceof Error ? error.message : 'Search failed', |
Contributor
There was a problem hiding this comment.
P2: Raw exception messages are emitted to client-facing session error events, exposing internal error details.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/agents/search/api.ts, line 103:
<comment>Raw exception messages are emitted to client-facing session error events, exposing internal error details.</comment>
<file context>
@@ -7,95 +7,102 @@ import { WidgetExecutor } from './widgets';
+ } catch (error) {
+ console.error('Error while running API search:', error);
+ session.emit('error', {
+ data: error instanceof Error ? error.message : 'Search failed',
});
}
</file context>
Suggested change
| data: error instanceof Error ? error.message : 'Search failed', | |
| data: 'Search failed', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
errorevent instead of leaving the client stuck on "Brainstorming"status: errorwhen they fail mid-flight so the UI can recover cleanlyVerification
./node_modules/.bin/tsc --noEmitnpm run buildFixes #965.
Summary by cubic
Prevented “Brainstorming” hangs by catching search pipeline errors and surfacing them to the client. Failures now emit a session
errorand are saved asstatus: 'error'so the UI can recover and allow retry. Fixes #965.APISearchAgentandSearchAgentflows in try/catch; failures triggersession.emit('error', { data: message })instead of hanging.status: 'error'and currentresponseBlocks; successful runs still save ascompleted.Written for commit 38300c8. Summary will update on new commits.