Skip to content
This repository was archived by the owner on Sep 13, 2026. It is now read-only.
This repository was archived by the owner on Sep 13, 2026. It is now read-only.

SSE connections hang in Coder environments due to proxy buffering #69

Description

@DivyMohan14

Server-Sent Events (SSE) connections to the /events endpoint hang indefinitely when AgentAPI is deployed in Coder workspaces. The connection opens successfully but no events are received due to proxy buffering.

Expected behavior
SSE connections should remain open and stream events in real-time for the chat interface.

I am using https://registry.coder.com/modules/coder/claude-code without tasks

Actual behavior:
EventSource shows readyState: 1 (OPEN) successfully
Connection appears established but hangs indefinitely
No SSE events are received (message_update, status_change)
Chat interface becomes non-functional - messages appear stuck
After ~60 seconds, connection may timeout and show error

Activity

  1. DivyMohan14 commented on Aug 27, 2025

    @DivyMohan14
    ContributorAuthor

    Coder's reverse proxy might be buffering HTTP responses by default, preventing real-time streaming of SSE data. The proxy waits to collect a "complete" response before forwarding, but SSE connections are meant to stay open indefinitely.

    I created a PR #70, and tested this, making this change actually made it work

    I think this issue coder/registry#433 might be related, the problem is as events sse call is not resolved the ui does not allow me to type

  2. johnstcn commented on Aug 29, 2025

    @johnstcn
    Member

    @DivyMohan14 While investigating coder/registry#433 I found that killing the agentapi process did not resolve the issue, which suggests to me that the issue is more on the Coder side?

  3. self-assigned this
    on Aug 29, 2025
  4. added theissue type on Aug 29, 2025
  5. DivyMohan14 commented on Aug 29, 2025

    @DivyMohan14
    ContributorAuthor

    Hey @johnstcn thanks for looking into this, regarding your comment for coder/registry#433, I found that killing the agentapi process did not resolve the issue -> wouldn't killing the agentapi process also kill the ui, I am not sure if I am missing something.

    I suspect this issue stems from the varied networking setups across different customer deployments - some may be running nginx, Cloudflare proxy, or other reverse proxies that buffer responses by default. To handle this variability and avoid requiring customers to configure their proxies correctly, I think implementing the fix directly in the application layer would be more robust. What are your thoughts on this?

  6. johnstcn commented on Aug 29, 2025

    @johnstcn
    Member

    @DivyMohan14 Yes it would, but keeping the chat UI running wasn't my focus. The issue in coder/coder seems to be related to an internal Coder process that keeps a workspace running as long as network activity is detected. My theory was that agentapi was perhaps keeping something open. I do suspect this issue is related, though.

  7. DivyMohan14 commented on Aug 29, 2025

    @DivyMohan14
    ContributorAuthor

    Got it, @johnstcn let me know will be more than happy to contribute on this.

  8. DivyMohan14 commented on Sep 9, 2025

    @DivyMohan14
    ContributorAuthor

    @johnstcn any update on this ?

  9. johnstcn commented on Sep 11, 2025

    @johnstcn
    Member

    Hey @DivyMohan14 -- I started looking into this.

    I'm unable to reproduce this issue with Coder directly (no reverse proxy in-betweeen).
    However, I can absolutely see how this could happen when you introduce other reverse proxies into the mix, and was able to reproduce this with a local Docker setup running nethack-console through AgentAPI.

    Let's continue discussion in your PR #70

  10. johnstcn commented on Sep 15, 2025

    @johnstcn
    Member

    @DivyMohan14 I've gone ahead and released v0.7.1 with the fix you proposed. Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions