Skip to content

fix: Slow side-question SSE clients can strand provider runs indefinitely - #984

Closed
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-8057a712
Closed

fix: Slow side-question SSE clients can strand provider runs indefinitely#984
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-8057a712

Conversation

@sam-saffron-jarvis

Copy link
Copy Markdown
Contributor

What changed

  • Wrapped side-question SSE responses with the existing per-write streaming response writer and its 30-second deadline, matching chat and response-run streams.
  • Added a regression test with a writer that blocks unless a write deadline is installed. The test verifies the handler returns, records a bounded nonzero deadline, and cancels the detached side-question provider.

Why this is high-value

The HTTP server intentionally has no global write timeout so long-lived SSE streams remain valid. Previously, side-question SSE was the exception to the per-write deadline rule: a suspended mobile browser or another client that stopped reading could block the handler in Write or Flush forever. Because the provider uses a detached context, that also left the side question active, made the session non-evictable, and caused later side questions to conflict. Bounding each write lets the existing write-error path cancel the provider and release the session.

Validation

  • gofmt -w cmd/serve_side_question.go cmd/serve_side_question_test.go
  • go build ./...
  • XDG_CONFIG_HOME=$(mktemp -d) go test ./...
  • go test ./cmd -run 'TestServeSideQuestion(Disconnect|SlowClient)' -count=100
  • git diff --check

@SamSaffron SamSaffron closed this Aug 2, 2026
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