feat(devserver): auto-detect free port for dev-ui#113961
Conversation
When port 7999 is already in use, the dev-ui server now scans for the next available port (up to +10) and prompts the user before starting rspack on it, rather than failing immediately.
858a2af to
fd05da3
Compare
- Normalize input to lowercase before comparison - Only treat 'y' or 'yes' as confirmation - Prevents 'no' and other responses from being treated as yes Co-authored-by: Jonas <JonasBa@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b2f87fb. Configure here.
- Empty input now accepts the default [Y/n] option - Aligns with standard CLI prompt conventions - Users can press Enter to quickly confirm alternate port Co-authored-by: Jonas <JonasBa@users.noreply.github.com>
scttcper
left a comment
There was a problem hiding this comment.
rspack does support port: 'auto' that we could use behind a flag i guess? wouldn't ask for confirmation like this version
As far as I can tell, there is no way to do auto + default right? We'd need that for when folks run the entire stack, so that it gets served from :8000 or whatever we use |
| const confirmed = await ask( | ||
| `Port ${requestedPort} is already in use. Start on port ${availablePort} instead? [Y/n] ` | ||
| ); | ||
|
|
||
| if (!confirmed) { | ||
| process.exit(0); | ||
| } |
There was a problem hiding this comment.
I've been meaning to do this for quite some time. Really glad you went ahead with it! 🎉 I agree with Scott's point, though... I'd probably skip asking for confirmation.
Remove the interactive confirmation prompt when the default dev-ui port is in use. The server now silently picks the next available port and prints a message to stderr instead of waiting for user input. Co-Authored-By: Claude <noreply@anthropic.com>
- Remove redundant 'use strict' (ES modules are always strict) - Unify port search into a single findNextPort call instead of a separate isPortAvailable check followed by findNextPort - Fix off-by-one in the exhausted-range error message Co-Authored-By: Claude <noreply@anthropic.com>
Previously only the first port (e.g. 7999) was reported as in use. Now all skipped ports are collected and logged so the message reflects every port that was actually taken. Co-Authored-By: Claude <noreply@anthropic.com>
|
@priscilawebdev @scttcper I've went ahead and swapped the confirmation for a log line, thanks for the suggestion! |
Update dev-server startup with a more DX friendly approach that checks if the port is used and prompts user to open the dev server on a next port. This allows folks running multiple checkouts or worktrees to more easily start dev servers and do work in parallel --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Jonas <JonasBa@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>

Update dev-server startup with a more DX friendly approach that checks if the port is used and prompts user to open the dev server on a next port. This allows folks running multiple checkouts or worktrees to more easily start dev servers and do work in parallel