fix(dev): use 127.0.0.1 instead of localhost for dev server (IPv6 resolution) - #1589
fix(dev): use 127.0.0.1 instead of localhost for dev server (IPv6 resolution)#1589hnbdr wants to merge 1 commit into
Conversation
…IPv6 resolution issues
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: Required CI passed. Waiting for automated review of the latest commit. If automated review does not start, a maintainer must restart it. Review-state labels are managed by this workflow; do not edit them manually. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Closes: #1588
Description
On systems where
localhostresolves to::1before127.0.0.1, the dev-mode webview fails to load: theaxios.get("http://localhost:<port>")health check ingetHMRHtmlContent()never reaches the Vite dev server, so Zoo Code shows "Local development server is not running..." even though the server is up.Fix is to stop relying on the ambiguous
localhostname in the dev loop and pin both sides to IPv4:src/core/webview/ClineProvider.ts:localServerUrland the injected@react-refreshimport URL now use127.0.0.1instead oflocalhost. This also keeps the CSP entries (script-src/connect-src/style-src, which are derived fromlocalServerUrl) consistent with what the webview actually loads.webview-ui/vite.config.ts: bind the dev server explicitly withhost: "127.0.0.1", keephmr: true(HMR now derives host/port from the server config instead of a separatehmr.host: "localhost"), pinport: 5173, and move thews.protocol: "ws"setting underserver.wssince HMR is no longer an object.Design note: choosing
127.0.0.1over::1matches the existing0.0.0.0fallback already present in the CSP and is deterministic on Windows where Node 17+ usesverbatimDNS ordering.Test Procedure
pnpm --dir src exec eslint --max-warnings=0 core/webview/ClineProvider.tsand webview lint — clean.tsc -binwebview-ui— clean.pnpm lintandpnpm check-types(turbo, all packages) via pre-commit/pre-push hooks — pass.Resolve-DnsName localhostreturns AAAA::1first), runpnpm dev+ launch the extension host, open the sidebar — the webview loads with working HMR and no "server is not running" error. Also verified the normal IPv4-first path still works.Pre-Submission Checklist
Visual Snapshots
N/A — no user-facing rendered state changes; this only affects the dev-mode bootstrap.
Videos (interaction / animation only)
N/A.
Documentation Updates
Additional Notes
No unit test added: the touched code path is dev-only bootstrap (
getHMRHtmlContent+ Vite server config) with no existing test harness around it; coverage is the manual repro in #1588.Get in Touch
hnbdr