Composer tool loop remains busy after H2 socket closes
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- node.js, typescript
Research direction
Read the end-stream and onClose branches in src/proxy.ts around lines 1493-1542, then trace the stderr and error handling in src/h2-bridge.mjs. Add a replay or integration test for multiple Composer tool/result turns with an injected H2 socket close; done means exactly one terminal state and no pending tool loop or busy state.
Written by the indexing model from the issue text.
Description
Environment
- OpenCode:
1.18.9 - Plugin:
opencode-cursor-oauth 0.1.1 - OS: macOS
- Node.js:
22.19.0 - Bun:
1.3.14
Summary
Composer can enter a busy state after a multi-turn tool loop when the H2 socket closes. The run does not emit a normal finish event, does not exit the tool loop, and does not return to idle. The same pressure test passes with Grok under the same client and tool setup.
Observed error text:
Cannot connect to API: The socket connection was closed unexpectedly
Sanitized timeline
11:02:12Z: last stream activity11:02:40Z: H2 socket closed11:06:28Z: later retry11:10:48Z: later retry
The timestamps are approximate and intentionally omit local identifiers and request details.
Expected behavior
When the H2 stream closes, the proxy should deterministically emit a terminal error or completion, close the associated stream state, and let the client exit the tool loop. A retry should either establish a clean new stream or fail with a bounded, visible error. The Composer run should never remain indefinitely busy without a finish/exiting-loop/idle transition.
Safe reproduction outline
- Configure OpenCode with the Cursor OAuth plugin and a Composer model.
- Run a read-only agent task that requires several sequential tool turns, such as inspecting files, searching for a symbol, and returning a final summary.
- Allow the task to continue through multiple tool-result round trips.
- Observe a stream/socket close during the loop.
- Observe that Composer remains busy instead of emitting a terminal event or returning to idle.
- Repeat the same multi-round read-only test with Grok; it completes successfully under the same pressure conditions.
No credentials, private payloads, session identifiers, or full prompts are included.
Network observations
At the time of investigation, basic unauthenticated DNS, TCP 443, TLS, HTTPS, and HTTP/2 connectivity to the Cursor host was normal, including repeated HTTP/2 root requests. There were also intermittent historical connection anomalies, including timeout, connection reset, DNS resolution, and TLS handshake errors. This suggests the proxy should handle transient H2 failures explicitly, but the issue is not explained by a persistent basic connectivity outage.
Suspected code areas
src/proxy.ts: clean end-stream andonClosebranches around lines 1493-1542src/h2-bridge.mjs: stderr and error handling for the child H2 bridge
Please verify that socket-close paths settle pending promises, clear stream/session state, and propagate a terminal event to the OpenAI-compatible response layer.
Validation suggestion
Add a replay or integration test that runs multiple Composer tool/result turns, injects an H2 socket close after stream activity, and asserts that the request reaches exactly one terminal state: completed, failed, or bounded retry. Also assert that no pending tool loop or busy state remains after the close.
- Dominant language
- TypeScript
- Stars
- 278
- Forks
- 31
- Avg merge
- 4h 13m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ephraimduncan/opencode-cursor
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
All issues in ephraimduncan/opencode-cursor
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·