Skip to content

fix(opencode): prevent RPC hangs on disconnected stderr - #43

Merged
nexxeln merged 2 commits into
anomalyco:devfrom
dbpolito:fix-rpc-stderr
Oct 5, 2026
Merged

nexxeln merged 2 commits into
anomalyco:devfrom
dbpolito:fix-rpc-stderr

Conversation

@dbpolito

@dbpolito dbpolito commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Issue

rift.create intermittently hung in OpenCode's background service even though the checkout was created. Restarting the service made one test succeed, but the hang returned on later calls.

The RPC bridge pipes hook output into process.stderr. When the host's stderr reader has disconnected, repeated RPC calls can leave the child's stderr stream paused. In an isolated reproduction, Rift exited successfully and stdout ended, but stderr never ended, so the close handler never resolved the tool call. Resuming stderr allowed close to fire.

Fix

Drain child stderr directly and retain its last 8 * 1024 bytes, including that diagnostic tail when the process exits unsuccessfully. This removes the dependency on the host's stderr while keeping useful failure output.

This follows OpenCode's own service contender, which consumes child stderr into an 8 KB tail, and its process runner, which drains stdout and stderr concurrently with waiting for exit.

Regression coverage runs three RPC calls in a Bun host whose stderr reader is disconnected and checks bounded diagnostics on failure. Hook output is no longer forwarded live to the host's stderr; structured RPC responses remain unchanged.

@nexxeln
nexxeln merged commit 858e7fe into anomalyco:dev Oct 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants