fix(server): do not HTTP-probe unknown local listeners #9832
main fromrefs/pull/9832/head·opened View on GitHubEvery discovered local listener gets HTTP-probed, including foreign processes that stall the probe for seconds.
Only probe discovered listeners on curated dev ports or ones owned by a known terminal; configured preview URLs are unchanged.
Ports #8561 as blast-radius reduction. Related to #8407 (not closing it): curated or terminal-owned listeners can still hit the underlying TLS-abort stall, which needs the socket-cleanup follow-up.
Built with muse-spark-1.3-contributor via OpenCode in T3 Code.
Note
Medium Risk Changes which local listeners get HTTP probes during preview scans; dev servers on non-curated ports may only appear if the user configures a URL or the terminal PID is registered.
Overview
Port discovery no longer sends HTTP(S) probes to every socket lsof (or Windows listener enumeration) finds. Discovered listeners are only probed when the port is in COMMON_DEV_PORTS or the owning PID is tied to a registered T3 terminal (server.terminal); other listeners are skipped so non-HTTP services are not hit with web requests or long probe timeouts.
Configured preview URLs are unchanged—they still go through the existing configured-URL probe path regardless of port. Tests cover skipping a high port with no terminal registration and probing that same port after registerTerminalProcesses.
Note
Stop HTTP-probing unknown local listeners in PortDiscovery#
Discovered listeners from lsof are now only probed when their port is in COMMON_DEV_PORTS or they are associated with a registered T3 terminal. Other sockets are skipped entirely, avoiding HTTP requests to foreign or unrelated listeners.
- Adds
isEligibleDiscoveredWebProbepredicate in PortScanner.ts and applies it in the scan candidate grouping loop - Updates module-level docs to reflect the new eligibility rule
- Adds tests for both foreign-listener exclusion and registered-terminal high-port probing
- Behavioral Change:
PortDiscovery.scanno longer HTTP-probes or publisheslsof-discovered listeners outsideCOMMON_DEV_PORTSwith no terminal association
Summary by CodeRabbit#
- Bug Fixes
- Improved preview server detection by avoiding HTTP probes for unrecognized listeners.
- Continued probing high-numbered listeners when they belong to registered terminals, improving detection of eligible preview servers.
- Tests
- Added coverage for filtering unrecognized listeners and recognizing eligible terminal-owned listeners.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
4ab29b7Macroscope's review found this PR approvable — This is a focused server bug fix that stops probing unrelated local listeners while preserving curated-port, terminal-owned, and explicitly configured preview behavior. The production logic is localized and accompanied by targeted tests for both skipped and retained listeners.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).c5d8973. Prior analysis still applies.No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
6be6fe46-c4a7-4f3c-8633-497ba3fa161b📥 Commits
Reviewing files that changed from the base of the PR and between 6c583620ff7ad3235b135af7107c0543467eecfa and c5d89733d3d87bd4ba096b299c885e1adfbd09a4.
📒 Files selected for processing (2)
apps/server/src/preview/PortScanner.test.tsapps/server/src/preview/PortScanner.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The preview port scanner now filters discovered listeners before HTTP probing. It probes curated development ports and listeners owned by registered T3 terminals, while tests verify both exclusion and inclusion cases.
Changes#
Preview port eligibility
Layer / File(s) Summary Filter discovered listeners before probing
apps/server/src/preview/PortScanner.tsThe scanner skips discovered servers that are not on curated development ports and are not associated with a registered terminal. Validate listener filtering
apps/server/src/preview/PortScanner.test.tsTests verify that unrelated listeners are not probed and that listeners owned by registered terminals are probed and returned. Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Merge Risk: ⚪ Minimal · up to
c5d89Discovered unrelated listeners are no longer sent HTTP probes, while curated ports, registered-terminal listeners, and configured preview URLs retain intended behavior. The change has focused coverage and is ready to merge.
Suggested reviewers:
juliusmarminge🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation Title check ✅ Passed The title clearly and concisely describes the main change: preventing HTTP probes to unknown local listeners. Description check ✅ Passed The description explains what changed, why it changed, scope, behavior for configured preview URLs, and test coverage. The omitted UI Changes section is not applicable, and the checklist requirements … Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2… Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. ✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Comment `@coderabbitai help` to get the list of available commands.Another real-world case for this one.
On Windows, pCloud Drive listens on 127.0.0.1:19191 as its single-instance channel. When the preview panel scans, T3 Code sends
GET http://localhost:19191/and thenhttps://localhost:19191/. pCloud treats each connection as a second launch and brings its main window to the front. So pCloud pops up twice, about 10 seconds apart, whenever a preview opens.Confirmed on current Nightly (Windows 11) by matching the trace ID in
server.trace.ndjson(PortDiscovery.probeWebUrl<pollTick<subscribeDiscoveredLocalServers) with the request pCloud logged. It has happened 13 times since Aug 18.This PR fixes it, since 19191 isn't a curated dev port and pCloud isn't a T3 terminal process. Would be great to see it merged.
juliusmarminge added labelsmacroscope-review
Note
Grok responding on behalf of Julius.
Thanks for this! #16687 just landed on main and covers the same ground: discovery now only probes listeners owned by T3 terminals and skips ports with any unowned listener, which is stricter than the curated-ports approach here. Closing this one as superseded.
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes