Select desktop backend port by sequential scan#1870
Conversation
- Add port scan helper with coverage - Keep backend startup on a stable preferred port
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This PR refactors desktop backend port selection from ephemeral reservation to predictable sequential scanning starting at port 3773. The change is self-contained, includes comprehensive unit tests, and the author has recent ownership of the affected code. Low risk runtime behavior change with clear intent. You can customize Macroscope's approvability policy. Learn more. |
So that your host is more stable across restarts when doing remote
What Changed
Why
UI Changes
Checklist
Note
Medium Risk
Changes desktop backend port selection during startup, which can affect app launch reliability and port-collision behavior if the preferred range is busy. Logic is straightforward and covered by new unit tests, but it touches the bootstrap path.
Overview
Desktop startup now selects the backend port by sequentially probing from a stable preferred port (default
3773) instead of reserving a random ephemeral loopback port.This introduces
resolveDesktopBackendPort(with validation and bounded scan) plus Vitest coverage, and updatesmain.tsbootstrap/logging to use the new resolver.Reviewed by Cursor Bugbot for commit ca8118f. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Select desktop backend port by sequential scan from port 3773
NetService.reserveLoopbackPortwith a newresolveDesktopBackendPortfunction in backendPort.ts that scans ports sequentially from a start port until it finds one available viacanListenOnHost.T3CODE_PORTis unset, the desktop app now selects a backend port by scanning fromDEFAULT_DESKTOP_BACKEND_PORT(3773) on the loopback host.startPortandmaxPortinputs and throws if no available port is found within the range.Macroscope summarized ca8118f.