fix(ui-server): auto-fallback to a random port on EADDRINUSE (#82)#119
Merged
Conversation
) The online installer launches the Web UI via `npm run start:built`, which runs ui/server/index.js directly. That path called `server.listen()` with no error handler, so a busy port (e.g. 3000/3001 already taken by other Node apps) crashed the process with an uncaught exception and aborted the install instead of recovering. Add listenWithPortFallback(): on EADDRINUSE, retry on a random high port (20000-59999) up to 5 times, then exit with a clear message. Random ports are used instead of preferred+1 because adjacent ports are often held by the same multi-port app. The actually-bound port is logged, used for the browser auto-open, and written back to process.env.SERVER_PORT so modules that self-reference it (e.g. routes/taskmaster.js) hit the right port. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Force *.sh (and docker-entrypoint.sh explicitly) to LF via .gitattributes. On Windows checkouts with core.autocrlf=true, git rewrote the Docker entrypoint to CRLF, which made the Linux container fail to start with `/usr/bin/env: 'bash\r': No such file or directory` and loop on restart. Pinning eol=lf prevents the regression on every clone/pull. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #82 — the auto-install script aborts when ports 3000/3001 are already in use.
The online installer launches the Web UI via
npm run start:built, which runsui/server/index.jsdirectly. That code path calledserver.listen()with no error handler, so a busy port crashed the process with an uncaughtEADDRINUSEexception and aborted the installation instead of recovering.Changes
ui/server/index.js:listenWithPortFallback(): onEADDRINUSE, retry on a random high port (20000–59999), up to 5 attempts, then exit with a clear, actionable message.preferred + 1because adjacent ports are frequently held by the same multi-port application that already took the preferred one.process.env.SERVER_PORTso modules that self-reference it (e.g.routes/taskmaster.js) hit the correct port after a fallback.Behavior
SERVER_PORTmanually.Testing
Verified the fallback logic in isolation:
Non-
EADDRINUSEerrors (bad host, permissions) still reject and are not silently retried.