Skip to content

fix: prevent SSE connection drops from silently truncating responses#7831

Merged
jh-block merged 2 commits intomainfrom
jhugo/review-pr-7830
Mar 12, 2026
Merged

fix: prevent SSE connection drops from silently truncating responses#7831
jh-block merged 2 commits intomainfrom
jhugo/review-pr-7830

Conversation

@jh-block
Copy link
Copy Markdown
Collaborator

Summary

When the SSE stream connection drops mid-response, the client was retrying the POST request indefinitely, causing duplicate agent tasks on the backend. PR #7830 capped retries at 1, but created a worse problem: the stream would end without a terminal Finish or Error event, making truncated responses appear successful.

This fix disables SSE retries entirely (sseMaxRetryAttempts: 0) on all three /reply call sites, since POST requests should never retry (they create work). When a connection drops, we now detect the premature stream end and show a toast notification instead of a full-page error, keeping the conversation visible while alerting the user the response may be incomplete.

Type of Change

  • Bug fix

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Manual testing needed to verify:

  • Toast appears when connection drops mid-stream
  • Conversation remains visible with partial response
  • User can retry by sending message again

Related Issues

Related to #7830

🤖 Generated with Claude Code

When the SSE connection drops mid-stream, the client was retrying the POST
request indefinitely, creating duplicate agent tasks on the backend. PR 7830
tried to cap retries at 1, but this created a worse problem: the stream would
end without a terminal Finish/Error event, making the truncated response appear
successful.

Fix this by disabling SSE retries entirely (sseMaxRetryAttempts: 0) on all
three /reply call sites. POST requests should never retry because they create
work on the backend. When a connection drops, we now detect the premature stream
end and show a toast notification rather than a full-page error, keeping the
conversation visible while alerting the user the response may be incomplete.

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29a94cc4a9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

jh-block added a commit that referenced this pull request Mar 12, 2026
Pass the AbortSignal to streamFromResponse so it can distinguish between
user-initiated aborts and genuine connection drops. Only show the toast
when the signal was not aborted.

Addresses code review feedback from PR #7831.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Pass the AbortSignal to streamFromResponse so it can distinguish between
user-initiated aborts and genuine connection drops. Only show the toast
when the signal was not aborted.

Addresses code review feedback from PR #7831.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@jh-block jh-block force-pushed the jhugo/review-pr-7830 branch from 96e3bdd to 901fb4e Compare March 12, 2026 10:40
@jh-block jh-block added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit f65530b Mar 12, 2026
21 checks passed
@jh-block jh-block deleted the jhugo/review-pr-7830 branch March 12, 2026 12:37
michaelneale added a commit that referenced this pull request Mar 15, 2026
* origin/main:
  Remove include from Cargo.toml in goose-mcp (#7838)
  Exit agent loop when tool call JSON fails to parse (#7840)
  chore: remove redundant husky prepare script (#7829)
  Add github actions workflow for unused deps (#7681)
  fix: prevent SSE connection drops from silently truncating responses (#7831)
  doc: Added notes in contribution guide for pnpm (#7833)
  add prefer-offline to pnpm config to skip unnecessary registry lookups (#7828)
  fix: remove dead read handler from DeveloperClient (#7821)
  fix: prevent SageMaker TGI from being marked configured when only Bedrock keys are set (#7284)
  fix: disable some computercontroller functionality when no $DISPLAY detected (#7824)
  test(acp): align provider and server test parity (#7822)
  fix(acp): register MCP extensions when resuming a session (#7806)

# Conflicts:
#	ui/desktop/src/hooks/useChatStream.ts
lifeizhou-ap added a commit that referenced this pull request Mar 16, 2026
* main: (191 commits)
  fix: add tool_choice and parallel_tool_calls to chatgpt_codex provider (#7867)
  fix: tool confirmation handling for multiple requests (#7856)
  Remove dead OllamaSetup onboarding flow (#7861)
  fix: resolve tokio::sync::Mutex deadlock in recipe retry path (#7832)
  Upgrade Electron 40.6.0 → 41.0.0 (#7851)
  Only show up to 50 lines of source code (#7578)
  fix: stop writing without error when hitting broken pipe for goose session list (#7858)
  feat(acp): add session/set_mode handler (#7801)
  Keep messages in sync (#7850)
  More acp tools (#7843)
  fix: skip upgrade-insecure-requests CSP for external HTTP backends (#7714)
  fix(shell): prevent hang when command backgrounds a child process (#7689)
  Remove include from Cargo.toml in goose-mcp (#7838)
  Exit agent loop when tool call JSON fails to parse (#7840)
  chore: remove redundant husky prepare script (#7829)
  Add github actions workflow for unused deps (#7681)
  fix: prevent SSE connection drops from silently truncating responses (#7831)
  doc: Added notes in contribution guide for pnpm (#7833)
  add prefer-offline to pnpm config to skip unnecessary registry lookups (#7828)
  fix: remove dead read handler from DeveloperClient (#7821)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants