anomalyco / anomalyco/opencode

`opencode serve` shows "Unexpected error" with no details when startup fails

Open
#48,784 1 comment 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Sep 13, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

When opencode serve fails to start (e.g. port conflict, missing config), the error output is:

Error: Unexpected error

ServeError

No actionable information is shown — no indication of what went wrong (port in use, missing config, permission error, etc.).

The root cause is in packages/opencode/src/index.ts lines 128-134: the catch block calls FormatError(e) which returns undefined for server startup errors (no matching _tag), then falls through to the generic "Unexpected error" + errorMessage(e). The Effect error from Server.listen likely has a structured cause that errorMessage() can't extract a useful string from — it just prints the _tag ("ServeError") with no underlying message.

OpenCode version

v1.18.29

Steps to reproduce
  1. Run opencode serve --port 4096 --hostname 0.0.0.0 on a port that's already in use (or from a directory where startup fails)
  2. Observe the error output — only "Unexpected error" and "ServeError" are shown
  3. Expected: the actual reason for the failure (e.g. "EADDRINUSE: port 4096 already in use" or the specific config error)
Operating System

Linux (Ubuntu)

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.