Skip to content

fix(desktop): auto-bump dev port when 5173 is occupied#1698

Open
Myestery wants to merge 2 commits intodifferent-ai:devfrom
Myestery:fix/desktop-dev-port-collision
Open

fix(desktop): auto-bump dev port when 5173 is occupied#1698
Myestery wants to merge 2 commits intodifferent-ai:devfrom
Myestery:fix/desktop-dev-port-collision

Conversation

@Myestery
Copy link
Copy Markdown

@Myestery Myestery commented May 7, 2026

Closes #1697

Summary

  • Detect actual port occupancy via connect-probe on IPv4 + IPv6 localhost (reuses existing probeHost); the previous listen-only check missed Vite's [::1]-only binding.
  • If default port is busy, scan upward for the first free port (5173-5272), rebuild startUrl + viteProbeUrls, log the bump.
  • Honor explicit PORT= override by failing fast instead of silently re-assigning.
  • Drop the portIsOpenForVite "port-open == Vite-ready" fallback that caused Electron to load stranger processes serving on 5173.
  • Tighten fetchWithTimeout default 4000ms → 1500ms; the 4s timeout caused ~12s probe hangs against non-HTTP TCP listeners on the bumped path.

apps/app/vite.config.ts is unchanged — strictPort: true stays correct now that the launcher guarantees a free port.

Test plan

  • pnpm dev with 5173 free → Vite + Electron come up on 5173.
  • python3 -m http.server 5173 (or raw TCP listener) in another shell, then pnpm dev → log shows Port 5173 busy — using 5174 instead, Electron loads the openwork app at 5174 (not the stranger).
  • PORT=5173 pnpm dev with 5173 busy → fails fast with a clear error.
  • PORT=6001 pnpm dev with 6001 free → Vite + Electron come up on 6001.

Myestery added 2 commits May 7, 2026 15:48
electron-dev.mjs hardcoded port 5173 with strictPort: true and treated
"port is open" as "Vite is ready", so a stranger process on 5173 caused
Electron to load whatever it served (or Vite to crash on spawn).

- Probe IPv4 + IPv6 localhost via existing probeHost to detect actual
  occupancy (not just IPv4 listen-bindability).
- If default port busy, scan upward (5173-5272) for first free port and
  rebuild startUrl + viteProbeUrls. Honor explicit PORT= by failing
  loud instead of silently bumping.
- Drop the "port-open == Vite-ready" fallback that masked collisions.
- Tighten fetchWithTimeout default 4000ms -> 1500ms; the 4s timeout
  caused 12s probe hangs against non-HTTP TCP listeners.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-landing Ready Ready Preview, Comment, Open in v0 May 7, 2026 3:05pm

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 7, 2026

@Myestery is attempting to deploy a commit to the Different AI Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

desktop: dev launcher loads stranger process when port 5173 is occupied

1 participant