Skip to content

fix(core): count websocket stream failures - #50955

Closed
rekram1-node wants to merge 1 commit into
devfrom
ws-loss-breaker
Closed

rekram1-node wants to merge 1 commit into
devfrom
ws-loss-breaker

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Issue for this PR

Related to #50213

Type of change

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

What does this PR do?

WebSocket stream finalization cleared the active exchange before poisoning the connection, so idle timeouts and response parser failures never incremented the five-loss HTTP fallback breaker.

Use exit-aware finalization and pass the failure decision explicitly to connection poisoning. Genuine stream failures now count once, while user interruption and clean terminal responses do not count. After five consecutive failures, the Session stays on HTTP as intended.

How did you verify your code works?

  • bun test test/session-model-transport.test.ts from packages/core
  • bun run check from the repository root

Added regressions for repeated idle timeouts, repeated parser failures, interruption exclusion, and the existing reader-loss test continues to guard against double counting.

Screenshots / recordings

Not applicable.

Checklist

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

@kvnloo

kvnloo commented Sep 25, 2026

Copy link
Copy Markdown

I checked the failure-accounting cases on head c0fd5c4 more closely.

The regressions pin three different outcomes:

  • five idle-timeout failures cause the sixth request to stay on HTTP, with only five WebSocket opens
  • five response-parser failures do the same
  • five user interruptions do not increment the breaker; the sixth request still uses WebSocket successfully

That distinction looks important. The breaker is counting actual failed exchanges, not simply every non-terminal stream exit, and interruption does not poison the transport.

The existing reader-loss coverage also continues to protect against double-counting.

Exact-head check and test workflows are green. I did not run this against a live provider WebSocket, but the state-machine boundary itself looks directly exercised here.

@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.

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.

2 participants