GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode serve: bind failures print bare "Unexpected error / ServeError" — the listen errno is never surfaced · Issue #38738 · anomalyco/opencode Closed as not planned Closed as not planned Copy link DescriptionDescriptionAny bind failure in There is no port, no hostname, no errno, no log path. The same output appears for a busy port, an unavailable address, and a privileged port — three different user mistakes, one identical message. Root cause
export async function listen(opts: ListenOptions): Promise<Listener> { const listener = await Effect.runPromise(listenEffect(opts)) The failure is Effect's export class ServeError extends Data.TaggedError("ServeError") {} // fields: { cause: unknown }
export function errorMessage(error: unknown): string { if (error instanceof Error) { if (error.message) return error.message // "" -> falls through if (error.name) return error.name // -> "ServeError" } So ImpactThis is not cosmetic — it makes bind failures undiagnosable. #37718 (Desktop WSL sidecar, mirrored networking) is the same two lines; the reporter had to run the port allocation sequence 8 times and read the Desktop sidecar source to guess at a cause that a single errno would have named. Proposed fixTwo independent changes, both small: 1. Unwrap if (error instanceof Error) { if (error.message) return error.message // Tagged errors (e.g. Effect's `ServeError`) carry an empty `message` and hide // the real failure in `cause`. Printing just the name tells the user nothing. if (error.cause !== undefined && error.cause !== null) { const inner = errorMessage(error.cause) if (inner && inner !== "unknown error") return error.name ? `${error.name}: ${inner}` : inner } if (error.name) return error.name } 2. Translate bind errno into an actionable message ( export async function listen(opts: ListenOptions): Promise<Listener> { const listener = await Effect.runPromise(listenEffect(opts)).catch((error) => { throw bindError(error, opts) }) ... } function bindError(error: unknown, opts: ListenOptions) { let cause: unknown = error const seen = new Set<unknown>() while (cause && typeof cause === "object" && !seen.has(cause)) { seen.add(cause) const code = (cause as { code?: unknown }).code const target = `${opts.hostname}:${opts.port}` if (code === "EADDRINUSE") return new Error( `Address ${target} is already in use. Choose a different --port, use --port 0 to pick a free one, ` + `or stop the process holding it (lsof -i :${opts.port}).`, { cause: error }, ) if (code === "EADDRNOTAVAIL") return new Error( `Cannot bind to ${target}: hostname "${opts.hostname}" is not an address on this machine.`, { cause: error }, ) if (code === "EACCES") return new Error(`Permission denied binding ${target}. Ports below 1024 require elevated privileges.`, { cause: error, }) cause = (cause as { cause?: unknown }).cause } const detail = cause instanceof Error && cause.message ? `: ${cause.message}` : "" return new Error(`Failed to start server on ${opts.hostname}:${opts.port}${detail}`, { cause: error }) } Verified on
Note: errno-based dispatch alone is not sufficient under Bun — see the companion issue on Separately, PluginsNone. OpenCode version1.17.9 (installed) and 1.18.4 ( Steps to reproduce
Also reproduces with any hostname not assigned to a local interface, e.g. Operating SystemmacOS 15.5 (arm64), Bun 1.3.14 TerminalGhostty Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |