fix(server): do not HTTP-probe unknown local listeners #8561
main fromrefs/pull/8561/head·opened View on GitHubWhat Changed#
PortDiscovery still HTTP-probes listeners so Preview can hide MySQL and Redis. It no longer GETs every local TCP socket.
A discovered listener is probed only when it is a curated dev port, a registered T3 terminal PID, or a configured Preview URL.
Why#
#6021 added HTML probes to classify servers. The classification is correct, but the probe itself writes HTTP onto unrelated binary listeners. #8407 reproduces that against thinkorswim's JxBrowser RPC socket: lsof finds a random high port, T3 sends GET / over HTTP then HTTPS, and the other app crashes during login.
Configured Preview URLs and ordinary Vite/webpack ports still get probed.
Closes #8407
Blast Radius#
Preview port discovery on macOS and Linux lsof, and the Windows listener scan. Non-HTTP services on curated ports are still probed, then excluded, same as today. Random system listeners are left untouched.
Verification#
Failing-then-passing regression in apps/server/src/preview/PortScanner.test.ts.
- Before the fix, a listener on port 63261 was returned after an HTTP GET.
- After the fix, that file is 21/21 passing. The same listener is probed when its PID is registered as a T3 terminal.
vp linton the two changed files: 0 errors.vp run --filter t3 typecheck: no errors in the changed file.
No UI chrome changed, so no screenshots.
Checklist#
- This PR is small and focused
- I explained what changed and why
- No UI change (screenshots not applicable)
- No motion change (video not applicable)
Note
Medium Risk Changes preview port-scan behavior on macOS/Linux and Windows fallback paths; misclassification could hide a dev server on a non-curated port, but configured URLs and terminal PIDs still get probed.
Overview
Preview port discovery no longer sends HTTP(S) GET probes to every TCP listener lsof finds on macOS/Linux. Discovered sockets are probed only when they sit on a curated dev port (e.g. Vite/webpack) or belong to a registered T3 terminal PID; configured Preview URLs are still probed as before.
This avoids writing HTTP onto unrelated binary/RPC listeners (e.g. random high ports from other apps) while keeping normal dev-server and terminal-owned port discovery. Tests cover a high port with no probe until registerTerminalProcesses maps the PID.
Note
Skip HTTP probing for unknown local listeners in PortDiscovery.scan#
Discovered listeners are now only HTTP-probed when on a curated dev port, owned by a registered T3 terminal, or named in a configured Preview URL. Adds isEligibleDiscoveredWebProbe in PortScanner.ts to gate probe URL construction and avoid sending HTTP to binary RPC listeners.
- Tests in PortScanner.test.ts verify the no-probe path for foreign listeners and the probe path for terminal-owned high-numbered ports
- Behavioral Change: non-eligible discovered listeners are no longer probed and will not appear in
PortDiscovery.scan()results
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
abaad2bMacroscope's review found this PR approvable — This is a small, self-contained server bug fix that prevents HTTP traffic from being sent to unrelated local binary listeners while preserving configured previews, common development ports, and T3 terminal-owned listeners. Regression tests cover both the no-probe and preserved-probe paths.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Checked this locally: merges cleanly onto current main and the eligibility gate does what it says. One thing worth knowing before it closes #8407 outright: the ~10s TLS stall in the Steam trace is undici keeping an in-flight connect alive after the fetch is aborted (see my note on #8407), so a binary service on a curated port or from a T3 terminal still gets probed and still blocks for 10s. Might be cleaner to say this PR narrows the blast radius and leave #8407 open for the socket cleanup.
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
f401c3b0-e0fc-40bb-84f1-9e2ba0181dd2You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.