Conversation
The dev launcher (`client/bin/start.js`) spawns the client as
`vite --port <CLIENT_PORT>`. Without `--strictPort`, Vite silently falls back
to the next free port when CLIENT_PORT is taken (e.g. a stale instance), but
the launcher still builds the "up and running" URL — and auto-opens the
browser — from the originally requested CLIENT_PORT. The user is sent to the
wrong (often stale) port while the real client listens elsewhere, and the
proxy's DNS-rebinding origin allow-list (pinned to
http://localhost:${CLIENT_PORT}) no longer matches either.
Fix:
- Pass `--strictPort` to Vite so it fails fast instead of drifting; the
launcher's URL is then always correct or startup fails loudly.
- Cancel the deferred announce/open timer if the client process exits first,
so we never advertise or open a URL for a client that isn't listening.
- Print a clear hint (free the port or set CLIENT_PORT) when the client exits
unexpectedly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FAFCf8AzpqyNF1oKZNGzh
11 tasks
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 a dev-launcher footgun: when the client port is already in use,
npm run devsends you to the wrong port and auto-opens a stale/incorrect page instead of failing clearly.Type of Change
Changes Made
The dev launcher (
client/bin/start.js) spawns the client asvite --port <CLIENT_PORT>. Without--strictPort, Vite silently falls back to the next free port whenCLIENT_PORTis taken (e.g. a leftover instance), but the launcher still builds the "🚀 up and running at" URL — and auto-opens the browser — from the originally requestedCLIENT_PORT. Result: you land on the wrong (often stale) port while the real client listens elsewhere, and the proxy's DNS-rebinding origin allow-list (pinned tohttp://localhost:${CLIENT_PORT}) no longer matches either — a confusing goose chase.--strictPortto Vite so it fails fast instead of drifting; the launcher's advertised URL is then always correct, or startup fails loudly.CLIENT_PORT) when the client exits unexpectedly.Related Issues
Testing
Test Results and/or Instructions
To reproduce the original bug: occupy the client port, then start dev — the browser opens the requested port (wrong/stale instance) even though Vite bound a different one.
To verify the fix:
python3 -m http.server 6274(or leave a priornpm run devrunning).npm run dev.localhost:6274.After: Vite exits immediately with a port-in-use error and the launcher prints a hint instead of opening a misleading URL. Freeing the port (or
CLIENT_PORT=6280 npm run dev) starts cleanly on the announced port.npm run prettier-checkandclientlint both pass. No behavior change on the happy path (port free).Checklist
npm run prettier-fix)Breaking Changes
None. When the port is free (the normal case) behavior is unchanged. The only behavioral change is that a port conflict now fails loudly instead of silently switching ports.
Additional Context
Separate from the "apply auth to all requests" work in PR #1 — this is an independent dev-experience fix and touches only
client/bin/start.js.🤖 Generated with Claude Code
Generated by Claude Code