Skip to content

fix(client): default SSE Accept headers - #48779

Closed
DEAN-Cherry wants to merge 2 commits into
anomalyco:devfrom
DEAN-Cherry:sse-accept-header
Closed

DEAN-Cherry wants to merge 2 commits into
anomalyco:devfrom
DEAN-Cherry:sse-accept-header

Conversation

@DEAN-Cherry

Copy link
Copy Markdown

Issue for this PR

Closes #48771

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Default generated Promise SSE requests to Accept: text/event-stream when no explicit Accept header is present. This avoids the first-response buffering observed with Kaspersky while preserving client, endpoint, and per-request header overrides.

The change is in the shared generator runtime, with the client regenerated so both event.subscribe and session.log use it. Non-SSE requests are unchanged.

How did you verify your code works?

  • packages/httpapi-codegen: 97 tests passed, including the emitted default and explicit-header overrides.
  • packages/client/test/promise.test.ts: 37 tests passed; client build and check:generated passed.
  • Full monorepo typecheck passed (35 tasks), and the four changed files pass Prettier.
  • With Kaspersky enabled, the patched SDK received the first event in 2-4 ms across three trials. Removing only the new header made all three control requests hit the two-second deadline against the same live backend.
  • The full client suite has the same six pre-existing Windows process-signal failures as the unmodified baseline (155 passed / 6 failed after this change; 154 / 6 before).

Screenshots / recordings

Not applicable: HTTP request-header change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@DEAN-Cherry

Copy link
Copy Markdown
Author

The issue already exists as #48771, and the PR description already contains Closes #48771.

This appears to be a non-default-branch edge case: this PR correctly targets v2, while the repository default is dev. GitHub documents that closing keywords do not create links for non-default branches. The standards workflow checks closingIssuesReferences, which is consequently empty, rather than the reference in the body.

I tried the supported addCloseIssueReferences mutation, but GitHub denied it because my account lacks permission to link issues in this repository. Could a maintainer manually link #48771 through the Development sidebar so the check can recognize it? The v2 base and code changes will remain unchanged.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@Upitep

Upitep commented Oct 26, 2026

Copy link
Copy Markdown

Could a maintainer please reconsider reopening this PR?

I'm experiencing the same issue on Windows with Kaspersky Endpoint Security and OpenCode 2.1.4.

Both the CLI and Desktop repeatedly lose their SSE connections:

  • CLI: Timed out connecting to server approximately every 2 seconds.
  • Desktop: continuous event stream disconnected and starting v2 background service messages.
  • The server itself responds correctly to HTTP API requests, including /api/model.
  • /api/event streams events and heartbeats correctly when tested with curl.
  • Clean reinstallations and fresh databases did not resolve the issue.

This makes OpenCode 2.x practically unusable on my machine.

The proposed Accept: text/event-stream fix appears highly relevant, especially given the author's successful Kaspersky tests.

This PR was closed by automated cleanup rather than a failed technical review. Could it please be reopened and considered for the current v2 release?

There also appears to be an issue-linking problem with #48771, as documented by the PR author.

Thank you!

@Upitep

Upitep commented Oct 26, 2026

Copy link
Copy Markdown

I'd like to confirm that this fix works in practice on Windows with Kaspersky Endpoint Security enabled.

We encountered persistent SSE connection failures after upgrading OpenCode from 2.0.6 to 2.1.4.

Symptoms:

  • CLI/TUI repeatedly showed Connection lost and Restarting service....
  • SSE requests timed out after approximately 2001 ms.
  • Desktop continuously logged event stream disconnected.
  • Desktop displayed "No models found", despite the backend correctly returning 10 models through /api/model.
  • Reinstalling OpenCode and resetting its databases did not resolve the issue.

We applied the fix from this PR to OpenCode 2.1.4 and rebuilt both the Windows CLI and Desktop.

Results:

  • First SSE event received in 33 ms, compared with the previous 2001 ms timeout.
  • SSE connection remained stable for 65 seconds, including heartbeats.
  • 140 tests passed, along with type checks and client regeneration.
  • Three consecutive TUI launches completed without connection failures.
  • Desktop successfully loaded all 10 models, including our custom alor-ai / MiniMax M2.7 provider.
  • We subsequently restored our shared user profile and credentials, and both patched applications are now working.

All of this was achieved without disabling Kaspersky or adding antivirus exclusions.

This confirms that the missing Accept: text/event-stream header can make both OpenCode CLI and Desktop unusable in a real Windows environment, and that the proposed fix resolves the issue.

Could a maintainer please reopen this PR, review it, and consider merging or porting the fix into the current release?

The PR was closed by automated cleanup, not because the patch failed review. Given that this affects both CLI and Desktop, I believe it deserves another look.

Thanks to @DEAN-Cherry for identifying the root cause and providing the fix!

dmitryprikhunov pushed a commit to dmitryprikhunov/opencode that referenced this pull request Nov 8, 2026
Port anomalyco#48779 to current dev. Preserve the current client runtime, regenerate from the generator, and update the integration test for server.info and experimental.session.log.

Original commits: 4aae4ef and 75b117d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V2 event streams can stall with Kaspersky without an SSE Accept header

2 participants