Skip to content

ECONNRESET / "Failed to drain Session" on every model request (Desktop 2.2.3, Windows 10, behind NaiveProxy) #60700

Closed as duplicate

Description

@VectorVegA

Description

markdown
Environment

  • OpenCode Desktop 2.2.3
  • Windows 10
  • Provider opencode-go, model deepseek-v4.1-flash
  • Network: Karing proxy client, single available node, NaiveProxy
  • Reproduces on all models including free ones; survives full reboot

Description

Every request to the model fails immediately with:

ECONNRESET: The socket connection was closed unexpectedly.

Server log (C:\Users\user\.local\share\opencode\log\opencode.log):

timestamp=2026-10-30T12:28:49.320Z level=ERROR message="Failed to drain Session"
cause="AI.Error: ECONNRESET: The socket connection was closed unexpectedly..."
sessionID=ses_e733bb8a8ffequlklXBRyMYalS

timestamp=2026-10-30T12:43:00.347Z level=ERROR message="Failed to drain Session"
cause="AI.Error: ECONNRESET: The socket connection was closed unexpectedly..."
sessionID=ses_e73633bc7ffdV6sW0EQRfRIszA

Stack trace contains Bun fetch and the server request loop:

AI.Error.Transport: ECONNRESET
TypeError: ECONNRESET: The socket connection was closed unexpectedly
  at POST
  at SessionStep.attempt
  at SessionRunner.runStep
  at SessionRunner.drain
  at ServerProcess.start

Expected: model response (streaming SSE).
Actual: connection reset during the POST, no response.

Already verified — please don't ask me to re-check these

  • Same API key, same endpoint, same model work from Python urllib.request on the same machine through the same proxy:
    • POST https://opencode.ai/zen/go/v1/chat/completions, stream=false → HTTP 200, OK
    • same with stream=true, Accept: text/event-stream → HTTP 200, SSE text received, stream finished
  • curl https://opencode.ai/inference/go/v1/models → HTTP 200 (server: cloudflare)
  • curl https://api.deepseek.com/models without auth → HTTP 401 (expected, HTTPS reachable)
  • TCP 443 to api.deepseek.com → TcpTestSucceeded: True
  • TLS handshake (OpenSSL 3.1.4) to opencode.ai and api.deepseek.com → TLSv1.3, verification OK, X25519
  • Karing's connection list shows OpenCode.exe → opencode.ai:443 routed through the proxy — the app is not bypassing it
  • Tried Rule / Global / TUN modes — no change
  • Full Windows reboot — no change
  • opencode CLI 1.19.3 from PowerShell — hangs, no TUI appears

Account, key, credits, model availability, DNS/TCP/TLS reachability and SSE streaming all work. The failure is specific to Desktop's request path.

Not tested / open hypotheses

  1. TLS ClientHello difference between Bun fetch and Python urllib — e.g. post-quantum key share X25519MLKEM768 producing a larger ClientHello dropped by the proxy or upstream network. Could not verify: local OpenSSL 3.1.4 rejects -groups X25519MLKEM768 (group cannot be set), and I have only one proxy node, so no comparative node test.
  2. Connection reuse / keep-alive behaviour of Desktop's HTTP client.
  3. Headers or request body differences Desktop adds.

What would let me narrow it down

  • A way to enable verbose network logging in Bun/Desktop's fetch (env var, debug flag, or a build with request dump).
  • TLS keylog support (SSLKEYLOGFILE / BoringSSL keylog) in Desktop, so the handshake can be captured and compared against a working one.
  • Whether Desktop's HTTP client uses HTTP/1.1 or HTTP/2 over TLS here.

Workaround currently in use: a small standalone Python GUI chat hitting the same endpoint — works fine.


Перед отправкой проверь: путь к логу я поставил реальный из `FUCK.md`, а версию `2.2.3` — если Desktop с тех пор обновился, поправь, иначе первым комментом будет «update to latest».

Остальное — если форма просит отдельно «Steps to reproduce» или «OpenCode version», просто раскидай куски из этого текста по полям.

### Plugins

_No response_

### OpenCode version

_No response_

### Steps to reproduce

_No response_

### Screenshot

_No response_

### Operating System

_No response_

### Terminal

_No response_

Activity

  1. opencodejr commented on Oct 30, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. The Python/OpenSSL comparison and the TLS hypotheses made this easy to place.

    I think this is a duplicate of #60399. That issue has been reproduced, and it matches your first hypothesis. OpenCode 2.x's bundled runtime (Bun) adds an X25519MLKEM768 post-quantum key share to the TLS ClientHello. That makes the ClientHello about 1.5 KB, so it is split across TCP segments, and filtering somewhere on the path to opencode.ai (Cloudflare) drops it. Every request then fails with ECONNRESET. Clients that send a smaller ClientHello still get through. Your OpenSSL 3.1.4 is one of them: as you found, it rejects that group. A proxy doesn't rule this out, because the inner TLS handshake still travels from the proxy's exit node to Cloudflare. A comment on #60399 also notes that v2 ignores HTTPS_PROXY for inference requests.

    #60399 has the measurements, the discussion of a client-side fix (limiting the TLS groups, e.g. X25519:P-256) and several temporary workarounds that other users posted.

    Possible duplicates and related issues, ordered from most to least likely:

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. For example, reply if you can show that the TLS handshake through your NaiveProxy exit completes and the reset happens later.

  2. magusy commented on Oct 30, 2026

    @magusy

    I am experiencing the same ECONNRESET error on the desktop app. It happens during model requests and prevents me from getting responses. I've confirmed that this is the same behavior described in this issue.

  3. opencodejr commented on Oct 31, 2026

    @opencodejr
    Contributor

    We haven't heard back, so I'm closing this as a duplicate of #60399. That issue is the same ECONNRESET on every request: Bun's larger post-quantum TLS ClientHello gets dropped on the network path to opencode.ai, even though Python/OpenSSL and curl get through. Please follow #60399 for updates and the workarounds posted there, and add your NaiveProxy/Karing details there if they help.

    If you find your case is different, for example the TLS handshake through the proxy completes and the reset happens later, reply here and we can reopen it.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions