Skip to content

Commit 77e04b5

Browse files
EbonsignoriCopilot
andauthored
handle mid-stream copilot error correctly (#55166)
Co-authored-by: Copilot <[email protected]>
1 parent 6ee8fc8 commit 77e04b5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/search/components/input/AskAIResults.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ export function AskAIResults({
195195
let parsedLine
196196
try {
197197
parsedLine = JSON.parse(line)
198+
// If midstream there is an error, like a connection reset / lost, our backend will send an error JSON
199+
if (parsedLine?.errors) {
200+
sendAISearchResultEvent({
201+
sources: [],
202+
message: JSON.stringify(parsedLine.errors),
203+
eventGroupId: askAIEventGroupId.current,
204+
couldNotAnswer: false,
205+
status: 500,
206+
})
207+
setAISearchError()
208+
return
209+
}
198210
} catch (e) {
199211
console.error(
200212
'Failed to parse JSON:',

0 commit comments

Comments
 (0)