Skip to content

acp: every session method hangs forever on Windows (Bun fetch starved by the /global/event SSE stream) #64686

Open

Description

@lihongfang16

Description

On Windows, opencode acp completes the initialize handshake, but every method that goes through the embedded SDK (session/new, session/list, ...) hangs forever — no timeout, no error, no log progress. The TUI is fine.

Root cause: Bun's fetch on Windows never completes a request once the process holds an open streaming HTTP response. The ACP server keeps a long-lived SSE subscription to its own embedded server (acp/event.ts, the global event connected log line) through the same SDK client that session/new uses for its 5 concurrent HTTP calls (loadDirectorySnapshot in acp/service.ts). Those requests are never dispatched, so the RPC hangs. Reproduces on 1.15 → 1.19.6, with a clean config, clean data dir, and --pure, with or without a system proxy.

Minimal repro of the runtime bug (bun 1.4.2 / 1.4.4 on Windows; node 23 on the same machine finishes in 12ms):

const sse = await fetch("http://127.0.0.1:23457/events")
;(async () => { const r = sse.body.getReader(); for(;;){ const {done} = await r.read(); if (done) break } })()
const rs = await Promise.allSettled(
  Array.from({length: 5}, () => fetch("http://127.0.0.1:23457/x", { signal: AbortSignal.timeout(8000) })),
)
// bun: 5x rejected (timeout, requests never reach the server)
// node: 5x fulfilled

Notes:

  • not proxy related (NO_PROXY makes no difference), not origin-pool related (different origins starve too, Connection: close is ignored)
  • not server related: node server + bun client fails, bun server + node client works
  • an open streaming response is enough — the body does not even need to be consumed
  • node:http in the same bun process is unaffected

Possibly related: #7112 (windows-specific, Zed agent window never loads), zed-industries/zed#65624.

Plugins

oh-my-openagent (reproducible with --pure, so unrelated)

OpenCode version

v1.19.6 (also verified on 1.19.4, 1.19.1, 1.19.0, 1.18.35, 1.17.10, 1.16.2, 1.15.13)

Steps to reproduce

  1. On Windows: opencode acp (any 1.15+ build)
  2. Send the ACP initialize request over stdio — responds fine
  3. Send session/new — never responds

Operating System

Windows 11 Pro 26100 (build 26300)

Activity

  1. opencodejr commented on Nov 18, 2026

    @opencodejr
    Contributor

    Thanks for the detailed root-cause write-up and the standalone Bun repro, that's very helpful.

    All the versions you tested (1.15 to 1.19.6) are OpenCode V1. V1 now only gets fixes for critical bugs, so this is unlikely to be fixed there. Please try OpenCode 2 (latest 2.2.7, npm package @opencode/cli). The migration guide covers the upgrade. Remove a package-managed V1 install before installing V2. The ACP setup is described at https://opencode.ai/docs/cli/acp/.

    One honest caveat: V2's ACP agent also subscribes to the server's event stream through its SDK client. So the Bun-on-Windows fetch behaviour you found might show up there too. If session/new also hangs with V2 on Windows, please reply here with the exact opencode --version and we'll look at it as a V2 bug.

    Related:

    I'm closing this issue now. Replying here reopens it, for example if it also happens on V2 or if you believe it is critical for V1.

  2. added
    area/ide-acp
    type/bug
    version/v1
    on Nov 18, 2026
  3. lihongfang16 commented on Nov 18, 2026

    @lihongfang16
    Author

    Reopening as requested: this also happens on V2 on Windows.

    opencode version: v2.3.2 (@opencode/cli 2.3.2, windows-x64, embedded Bun 1.4.4), Windows 11 Pro build 26300.

    Same symptom: opencode acp → initialize responds in ~0.6s, session/new hangs forever (no timeout, no error, no further logs from the serve --stdio --port 0 child).

    It also looks like the same starvation shape as V1: while session/new is pending, the only loopback connection pair is the one between the CLI process and the serve child (the event stream), and no new TCP connection is ever established — the SDK requests are queued behind it at the fetch layer and never dispatched. V2's sse: false in agentCapabilities.mcpCapabilities suggests HTTP transports are affected knowingly; but the ACP agent's own event subscription still holds a long-lived streaming response on the same runtime.

    For reference, on V1 the same machine now passes a full ACP e2e (session/new → session/prompt → streamed model reply) with PR #64688, which swaps the SDK transport to node:http on win32. If V2's ACP event subscription also goes through Bun's fetch, the same transport swap should apply there.

  4. opencodejr commented on Nov 18, 2026

    @opencodejr
    Contributor

    Thanks for confirming this on 2.3.2. I installed @opencode/[email protected] and ran the same stdio sequence (initialize, then session/new) against opencode acp. Our test environment only runs Linux, and there session/new answers immediately with a session ID. That fits your finding that the hang is specific to Bun on Windows, but I couldn't check the Windows behaviour myself.

    This needs a maintainer with a Windows machine to confirm. Your standalone Bun script and the transport change in #64688 give them a direct way to test it and a possible fix direction.

  5. lihongfang16 commented on Nov 19, 2026

    @lihongfang16
    Author

    Update for whoever picks this up with a Windows machine — the V2 code path confirms the same shape as V1:

    In V2, opencode acp spawns the server child via packages/cli/src/services/standalone.ts: serve --stdio --port 0. The child prints a {"url": ...} readiness line on stdout and everything after that (including the ACP event stream subscription) goes over HTTP fetch to that URL. On Windows with Bun 1.4.4, holding that long-lived streaming response open starves all later fetches in the CLI process, so session/new's SDK calls never get dispatched — matching what I see on the wire: the only loopback connection pair is the event stream, and no new connection is ever attempted while session/new is pending.

    Suggested fix mirrors #64688: route the CLI-side SDK fetch (or at least the event stream) through node:http on win32, which does not exhibit the starvation.

  6. DEV-S-SHAH commented on Nov 19, 2026

    @DEV-S-SHAH

    Triaged: Bun fetch starved by /global/event SSE stream on Windows. Investigating connection handling.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ide-acpplatform/windowsseverity:hightype/bugversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions