You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): silent exit on port conflict — no error logged #21170
When opencode serve --port <N> fails because the port is already in use, the process exits silently with only 3 log lines (version info + config loading). No error is logged — no "port in use", no "EADDRINUSE", no stack trace. The log file and stderr both show nothing beyond config loading.
Expected Behavior
The serve should log an explicit error: Failed to start server: port <N> is already in use (PID <X>) and exit with a non-zero code.
Actual Behavior
Process exits with 3 log lines:
INFO service=default version=1.3.13-sami.20260406-015434 args=["serve","--port","4096"] opencode
INFO service=config path=~/.config/opencode/opencode.json loading
INFO service=config path=~/.config/opencode/opencode.json loading
No error. Exit code 0.
Root Cause
In packages/opencode/src/server/server.ts, tryServe() (line 282-287) catches the Bun.serve() error and returns undefined. Line 290 throws Failed to start server on port ${opts.port} but this may be caught higher up without logging.
consttryServe=(port: number)=>{try{returnBun.serve({ ...args, port })}catch{returnundefined// swallows the actual error}}
Impact
We hit this three times during fleet deployment (sami-claude, sami, ghost-wispr) — each time a stale serve was holding the port. Debugging took 10-30 minutes each time because there was no error to indicate the port conflict.
Suggested Fix
Log the caught error in tryServe() instead of swallowing it
Check if the port is in use before attempting to bind (e.g. lsof -ti :<port>)
Activity
github-actions commentedon Apr 6, 2026
This issue might be a duplicate of existing issues. Please check:
sjawhar commentedon Apr 6, 2026
Duplicate of #19272. Closing.