You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
acp: every session method hangs forever on Windows (Bun fetch starved by the /global/event SSE stream) #64686
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):
constsse=awaitfetch("http://127.0.0.1:23457/events");(async()=>{constr=sse.body.getReader();for(;;){const{done}=awaitr.read();if(done)break}})()constrs=awaitPromise.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
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.
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.
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.
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.
Activity
opencodejr commentedon Nov 18, 2026
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
fetchbehaviour you found might show up there too. Ifsession/newalso hangs with V2 on Windows, please reply here with the exactopencode --versionand we'll look at it as a V2 bug.Related:
opencode runhang while waiting for the first event on the event stream (different cause, same symptom)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.
lihongfang16 commentedon Nov 18, 2026
Reopening as requested: this also happens on V2 on Windows.
opencode version: v2.3.2 (@opencode/cli2.3.2, windows-x64, embedded Bun 1.4.4), Windows 11 Pro build 26300.Same symptom:
opencode acp→initializeresponds in ~0.6s,session/newhangs forever (no timeout, no error, no further logs from theserve --stdio --port 0child).It also looks like the same starvation shape as V1: while
session/newis pending, the only loopback connection pair is the one between the CLI process and theservechild (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'ssse: falseinagentCapabilities.mcpCapabilitiessuggests 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 tonode:httpon win32. If V2's ACP event subscription also goes through Bun'sfetch, the same transport swap should apply there.opencodejr commentedon Nov 18, 2026
Thanks for confirming this on 2.3.2. I installed
@opencode/[email protected]and ran the same stdio sequence (initialize, thensession/new) againstopencode acp. Our test environment only runs Linux, and theresession/newanswers 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.
lihongfang16 commentedon Nov 19, 2026
Update for whoever picks this up with a Windows machine — the V2 code path confirms the same shape as V1:
In V2,
opencode acpspawns the server child viapackages/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, sosession/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 whilesession/newis pending.Suggested fix mirrors #64688: route the CLI-side SDK fetch (or at least the event stream) through
node:httpon win32, which does not exhibit the starvation.DEV-S-SHAH commentedon Nov 19, 2026
Triaged: Bun fetch starved by /global/event SSE stream on Windows. Investigating connection handling.
fix(cli): run acp over node:http to prevent sse stream starvation (an…