anomalyco / anomalyco/opencode
Worker's uncaughtException and unhandledRejection handlers are empty, so worker crashes leave no trace
@simonklee is already working on this.
Since Sep 3, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Both process-level handlers in packages/opencode/src/cli/tui/worker.ts are empty functions:
const onUnhandledRejection = (_error: unknown) => {}
const onUncaughtException = (_error: Error) => {}
process.on("unhandledRejection", onUnhandledRejection)
process.on("uncaughtException", onUncaughtException)
Registering a handler suppresses Node's default behaviour — print the stack, exit non-zero — so an empty one turns a worker crash into silence. Nothing is written to the log, and the TUI keeps talking to a worker that may be gone.
#42885 covers the RPC path (a throwing handler, a killed worker), but it doesn't touch these two handlers, so a failure that never crosses the RPC boundary stays invisible.
Logging the error before returning would be enough — synchronously, since the process may be about to exit. In a build where the handler does that, the one crash it caught over several weeks was Error: EIO: i/o error, write, which is otherwise lost entirely.
Happy to open a PR if that's welcome.
Steps to reproduce
- In
packages/opencode/src/cli/tui/worker.ts, addsetTimeout(() => { throw new Error("boom") }, 4000)before theprocess.oncalls. - Run
bun dev . - After 4 seconds: the TUI is still up,
boomappears nowhere — not on stdout, not in the log directory.
OpenCode version
1.18.27
Operating System
Ubuntu 24.04 (WSL2)
Terminal
Ubuntu-24.04
Contributor guide
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.
Assessment
This issue has not been assessed yet.