[PR #1224] [CLOSED] feat(server): improve server startup error handling #9852

Closed
opened 2026-02-16 18:14:16 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1224
Author: @braden-w
Created: 7/22/2025
Status: Closed

Base: devHead: feat/server-error-handling


📝 Commits (1)

  • 7e86d06 feat(server): improve server startup error handling

📊 Changes

2 files changed (+32 additions, -7 deletions)

View changed files

📝 packages/opencode/src/cli/error.ts (+5 -0)
📝 packages/opencode/src/server/server.ts (+27 -7)

📄 Description

Previously, when users ran the opencode serve command and the default port 4096 was already in use, they would see an unexpected error message:

Error: Unexpected error, check log file at ~/.local/share/opencode/log/dev.log for more details
error: script "dev" exited with code 1

The implementation wraps Bun.serve() calls in try-catch blocks and maps them into ServerStartError errors using the established NamedError pattern. The original Bun error message (like "Failed to start server. Is port 4096 in use?") is preserved and displayed directly to users via the FormatError system.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1224 **Author:** [@braden-w](https://github.com/braden-w) **Created:** 7/22/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feat/server-error-handling` --- ### 📝 Commits (1) - [`7e86d06`](https://github.com/anomalyco/opencode/commit/7e86d06bde9def8acf5ae3521e9f274fb427f218) feat(server): improve server startup error handling ### 📊 Changes **2 files changed** (+32 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/cli/error.ts` (+5 -0) 📝 `packages/opencode/src/server/server.ts` (+27 -7) </details> ### 📄 Description Previously, when users ran the `opencode serve` command and the default port 4096 was already in use, they would see an unexpected error message: ```bash Error: Unexpected error, check log file at ~/.local/share/opencode/log/dev.log for more details error: script "dev" exited with code 1 ``` The implementation wraps Bun.serve() calls in try-catch blocks and maps them into `ServerStartError` errors using the established NamedError pattern. The original Bun error message (like "Failed to start server. Is port 4096 in use?") is preserved and displayed directly to users via the FormatError system. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:16 -05:00
yindo closed this issue 2026-02-16 18:14:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9852