anomalyco / anomalyco/opencode

Worker's uncaughtException and unhandledRejection handlers are empty, so worker crashes leave no trace

Open
#47,113 0 comments 0 reactions 1 assignee View on GitHub

@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
  1. In packages/opencode/src/cli/tui/worker.ts, add setTimeout(() => { throw new Error("boom") }, 4000) before the process.on calls.
  2. Run bun dev .
  3. After 4 seconds: the TUI is still up, boom appears 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.