Repository navigation
Conversation
Co-authored-by: Cursor <[email protected]>
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Related PR FoundPR #41968: fix(cli): survive broken stdio pipes This PR appears to be related as it also addresses broken pipe issues in stdio handling. While your current PR (#43258) specifically focuses on guarding child stdin against post-exit EPIPE in the MCP spawner, PR #41968 handles similar broken pipe scenarios in the CLI. Both PRs address process survival when stdio pipes are broken, though in different contexts. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #43257
Type of change
What does this PR do?
A local MCP server whose command dies instantly (e.g. its configured cwd no longer exists) crashes the whole v2 background service, and the client respawns it forever — the TUI just loops "restarting service".
The crash is an uncaught
EPIPE: broken pipe, send. The MCP transport writes the initialize frame into the child's stdin while it's exiting; once the sink finishes andend()flushes into the broken pipe, the writable's destroy path emitserrorasynchronously. At that point nothing is subscribed toproc.stdin's error event, so it's process-fatal. Bun 1.4 (which the v2 binary ships with) surfaces this late EPIPE; Bun 1.3 doesn't.Fix: attach a no-op
errorlistener toproc.stdinin the cross-spawn spawner before wrapping it in the sink. Errors during active writes still reach the sink through its ownonErrorand fail the connect with a typed error as before — this only stops the late, post-sink EPIPE from killing the process.How did you verify your code works?
bun run test+bun typecheckin packages/core and packages/util (2 pre-existing failures in core are unrelated: one needs live AWS creds, one is a flaky watcher test that passes in isolation).Screenshots / recordings
Not a UI change.
Checklist
Made with Cursor