Skip to content

fix: Copilot provider can hang forever when a stream consumer goes away#370

Closed
sam-saffron-jarvis wants to merge 1 commit intoSamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-db956dd6
Closed

fix: Copilot provider can hang forever when a stream consumer goes away#370
sam-saffron-jarvis wants to merge 1 commit intoSamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-db956dd6

Conversation

@sam-saffron-jarvis
Copy link
Copy Markdown
Contributor

What

  • make Copilot chat-completions streaming emit events through a context-aware helper instead of blocking channel sends
  • stop the producer loop cleanly when the stream context is cancelled while emitting text, tool-call, usage, or done events
  • add a regression test covering stream closure when the consumer stops reading mid-stream

Why

Copilot was writing directly to the internal event channel. If a consumer disconnected or cancelled and stopped draining events, the buffered channel could fill and leave the producer goroutine blocked forever on events <- .... That prevented Close() from finishing, leaked the HTTP response body, and could leave runs or sessions stuck instead of shutting down cleanly.

@SamSaffron SamSaffron closed this Apr 15, 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