Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ui/desktop/src/hooks/useChatStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ export function useChatStream({
},
throwOnError: true,
signal: abortControllerRef.current.signal,
sseMaxRetryAttempts: 1,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat dropped SSE stream as an error, not a normal finish

Setting sseMaxRetryAttempts: 1 here causes the SSE client to stop immediately on the first transport failure (ui/desktop/src/api/core/serverSentEvents.gen.ts:229), and when that happens streamFromResponse() exits its for await loop and calls onFinish() as if the response completed successfully (ui/desktop/src/hooks/useChatStream.ts, streamFromResponse). In a transient TLS/Electron blip, users can therefore get a truncated assistant message with no error state, which is a correctness regression compared to surfacing a stream failure.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well if you have this, it spams the backend with every single network change.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this is unrealistic as it is localhost anyway.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is happening on localhost we must have another bug surely. can you share any instructions for reproducing it on localhost? I haven't been able to so far

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can get the broken retry behaviour to happen using goose on one computer and goosed on another and deliberately making the network bad between them. The retries are buggy because we repeat the POST and there's no event deduplication. So there's definitely a bug to fix here, but in case it was a real network problem you would want the user to know that the connection dropped and the response was truncated.

I haven't been able to make it happen on localhost so far, and the localhost case sounds like a slightly different issue since it's unlikely to be a real network problem.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce the localhost issue, it's a bad interaction of some Chromium behaviour and some Chromium bugs + our broken retry logic. more details on Slack but I've merged in a fix plus some user feedback in #7831

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will follow up with retry improvements although the move to ACP may also help there

});

await streamFromResponse(stream, currentMessages, dispatch, onFinish, sessionId);
Expand Down Expand Up @@ -634,6 +635,7 @@ export function useChatStream({
},
throwOnError: true,
signal: abortControllerRef.current.signal,
sseMaxRetryAttempts: 1,
});

await streamFromResponse(stream, currentMessages, dispatch, onFinish, sessionId);
Expand Down Expand Up @@ -773,6 +775,7 @@ export function useChatStream({
},
throwOnError: true,
signal: abortControllerRef.current.signal,
sseMaxRetryAttempts: 1,
});

await streamFromResponse(stream, messagesForUI, dispatch, onFinish, targetSessionId);
Expand Down
Loading