[Bug]: Preview PortScanner sends HTTP(S) to unrelated listeners and can crash other apps #8407
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- Run T3 Code Alpha 0.0.34 on macOS.
- In Settings → General → Legacy features, enable Sidebar (legacy). Browser Preview does not need to be open.
- Leave T3 Code running with the legacy sidebar mounted.
PortDiscovery.pollTickcontinues approximately every three seconds because the sidebar subscribes to environment-wide discovered servers. - Start a local non-HTTP service that expects a binary handshake. The reproduced service is the private JxBrowser RPC listener created during thinkorswim login.
- T3 Code's
PortScannerdiscovers the listener through the system-widelsofscan and sendsGET /first over HTTP and then HTTPS. - Observe the foreign-protocol connection in T3's trace and the receiving application's failure.
An alternative retainer is an empty Browser Preview surface, which also subscribes to discovered servers.
The thinkorswim reproduction is intermittent because its JxBrowser listener uses a random loopback port and the failure depends on timing during browser startup. It has occurred repeatedly during login after reboot/update.
Expected behavior#
Browser Preview discovery should not write HTTP protocol bytes to arbitrary system-wide TCP listeners. Active probes should be limited to T3-managed process trees, explicitly configured Preview URLs, or another opt-in/safe eligibility boundary.
Actual behavior#
On macOS/Linux, PortScanner enumerates all listening TCP sockets. Terminal ownership is recorded as metadata but is not an eligibility filter. For every discovered listener, T3 constructs HTTP and HTTPS URLs and performs GET requests.
Preview does not need to be open. The legacy sidebar invokes useThreadDiscoveredPorts for displayed threads, which maps to the environment-wide previewEnvironment.discoveredServers query. With legacySidebarEnabled: true, a live trace showed PortDiscovery.pollTick approximately every three seconds while no Preview interaction was occurring. The query layer may deduplicate identical environment subscriptions, but the mounted legacy sidebar still retains at least one discovery subscription.
This behavior was introduced by #6021 to distinguish browser-ready servers from services such as MySQL and Redis. A listener must therefore receive HTTP traffic before T3 decides that it is not an HTTP service.
In the captured reproduction, T3 probed thinkorswim's JxBrowser 9.0.1 binary RPC listener on port 63261. thinkorswim then raised a NullPointerException in the connection handshake and hung during login.
Relevant source:
- Legacy-sidebar retention path: https://github.com/pingdotgg/t3code/blob/9fd788b5a92254a2afa72c2a53513ed2cb730f0d/apps/web/src/components/LegacySidebar.tsx#L374-L386
- Discovery-query mapping: https://github.com/pingdotgg/t3code/blob/9fd788b5a92254a2afa72c2a53513ed2cb730f0d/apps/web/src/portDiscoveryState.ts#L53-L65
- WebSocket retain/scan subscription: https://github.com/pingdotgg/t3code/blob/9fd788b5a92254a2afa72c2a53513ed2cb730f0d/apps/server/src/ws.ts#L2159-L2184
- Empty-Preview retention path: https://github.com/pingdotgg/t3code/blob/9fd788b5a92254a2afa72c2a53513ed2cb730f0d/apps/web/src/features/preview/PreviewEmptyState.tsx#L20-L31
- Listener enumeration: https://github.com/pingdotgg/t3code/blob/9fd788b5a92254a2afa72c2a53513ed2cb730f0d/apps/server/src/preview/PortScanner.ts#L480-L535
- HTTP/HTTPS candidate construction: https://github.com/pingdotgg/t3code/blob/9fd788b5a92254a2afa72c2a53513ed2cb730f0d/apps/server/src/preview/PortScanner.ts#L350-L390
- HTTP
GETclassifier: https://github.com/pingdotgg/t3code/blob/9fd788b5a92254a2afa72c2a53513ed2cb730f0d/apps/server/src/preview/PortScanner.ts#L329-L348 - Three-second polling: https://github.com/pingdotgg/t3code/blob/9fd788b5a92254a2afa72c2a53513ed2cb730f0d/apps/server/src/preview/PortScanner.ts#L550-L583
Impact#
Major degradation or frequent failure. The scanner can be a hidden background side effect of ordinary T3 use rather than only an effect of explicitly using Browser Preview.
Version or commit#
T3 Code Alpha 0.0.34; behavior introduced by merged PR #6021 / commit 9fd788b5a92254a2afa72c2a53513ed2cb730f0d
Environment#
- macOS 26.6.2, Apple Silicon
- T3 Code Alpha 0.0.34
- thinkorswim build 1993.0.48
- Java 21.0.5 aarch64
- JxBrowser 9.0.1 / Chromium 147.0.7727.138
Logs or stack traces#
T3 server trace (EDT):
2026-08-27 09:32:07.068 PortDiscovery http.client GET http://localhost:63261/
2026-08-27 09:32:08.070 HTTP probe ends after 1001.755 ms; HTTPS probe begins
thinkorswim client.log (EDT):
2026-08-27 09:32:07.212 OAuth logged in
2026-08-27 09:32:08.079 Error in IPC Server Thread
java.lang.NullPointerException: Cannot invoke
"com.teamdev.jxbrowser.internal.rpc.ConnectionCreated.getConnectionData()"
because "connectionCreated" is null
at com.teamdev.jxbrowser.internal.rpc.transport.ConnectionServer$AcceptConnections.acceptConnection(ConnectionServer.java:191)
at com.teamdev.jxbrowser.internal.rpc.transport.ConnectionServer$AcceptConnections.run(ConnectionServer.java:170)
at java.base/java.lang.Thread.run(Unknown Source)
Runtime socket inspection confirmed that the T3 server process was connected to the same JxBrowser listener port. The synchronized timestamps establish T3's probe as the trigger; the null dereference itself is also a JxBrowser input-validation defect.
Workaround#
Disable Settings → General → Legacy features → Sidebar (legacy), close any empty Browser Preview surfaces, and wait for discovery retainers to release before launching thinkorswim. Quitting T3 Code during thinkorswim startup is a fallback. A per-process outbound firewall rule preventing T3 from connecting to random high-numbered loopback ports is another containment option. These measures do not fix the root cause.
Related but non-fixing work: #4187, #5900, #6254, and #7789.
Looked at why the TLS probe lingers for ~10.45s despite the 1s budget, since that is the part #8561 does not touch. The Effect timeout does fire and
FetchHttpClientdoes pass anAbortSignalto fetch, so the request is aborted at 1s. The stall is inside undici: when a request is aborted while the client is still connecting,resume()just drops it from the queue and the in-flight connect, TLS handshake included, keeps going until the connector's own timeout, which defaults to 10s (connect.js,timeout == null ? 10e3). That matches the trace to within a few tens of ms. So the eligibility filter in #8561 stops the scanner from touching random listeners, but a non-HTTP service on a curated port or spawned from a T3 terminal still gets both probes and still holds the socket for 10s after we gave up. Closing that needs the probe to own its connection, either a dedicated undici Agent with a shortconnect.timeoutfor the scanner, or a raw socket probe we can destroy on cancel, plus the TLS-prefix listener test asked for above.This also appears to interrupt T3?s own Antigravity Google sign-in on Windows, using Nightly
0.0.39-nightly.20260904.1280and managed ACP runtime1.1.1.The sign-in URL appears, but authentication fails within seconds. In the server trace, PortDiscovery sends
GET /without OAuth parameters to the exact callback port. It returns HTTP 200 fromWSGIServer/0.2 CPython/3.10.4; approximately 10 ms after the request starts,RpcClient.authenticatefails withOnboarding failed: The authentication flow did not complete successfully.The authentication request lasted 7.5 seconds, while T3?s configured sign-in timeout is five minutes. The browser subsequently receives connection refused.
This strongly suggests the discovery probe consumes the callback before Google returns. I have not yet verified the flow with scanning disabled.
Confirmed still occurring in T3 Code
0.0.43-nightly.20260925.2251, commit1c1270663880, on Linux / Hyprland / Wayland (September 25, 2026).The user reports freezes across Steam games while T3 is running. During this investigation Rocket League was running under Proton. Inspection of the installed server bundle and T3's existing
server.trace.ndjson, matched against listener ownership fromss -ltnp, confirmed that preview discovery sends unsolicited HTTP and HTTPS probes to Steam, Discord, and the game process itself:Listener owner Local port Observed requests in the inspected trace Median interval Discord 6463 56 HTTP + 56 HTTPS ~17.2 s Steam 27036, 38379, 41659, 57343 56 HTTP + 56 HTTPS per port ~17.2 s RocketLeague.exe 37207 14 HTTP + 14 HTTPS ~17.4 s The installed
PortDiscoveryimplementation still:- Runs
lsof -iTCP -sTCP:LISTEN -P -n -F pcnwith a three-second polling delay while retained. - Records terminal ownership as metadata without using it to exclude unrelated listeners.
- Constructs
http://localhost:<port>andhttps://localhost:<port>candidates for every discovered listener. - Uses a 15-second probe cache, one-second per-probe timeout, and concurrency 16.
Representative trace fields (only local service URLs and timings):
http.client GET http://localhost:6463/ status=404 durationMs=5.321274 http.client GET http://localhost:37207/ status=404 durationMs=63.571139 http.client GET https://localhost:37207/ durationMs=97.918716 http.client GET http://localhost:27036/ durationMs=999.700283 http.client GET http://localhost:57343/ durationMs=1000.669686 http.client GET https://localhost:57343/ durationMs=999.920081Evidence boundary: This independently confirms continued probing of unrelated services on the September 25 nightly. We did not capture game frame times or Steam syscalls, measure socket closure after cancellation, or complete a T3-off comparison. Request durations are not measurements of game freezes. The user's freeze report is consistent with #9526, but this investigation does not independently establish its blocking mechanism.
Please restrict active probes to T3-owned development-server processes or explicitly configured URLs, and provide a discovery off switch. Static Steam/Discord port exclusions alone would miss dynamically allocated Steam and game listeners. The timeout/socket-cleanup regression coverage described in #9526 also remains relevant.
Posted on behalf of the affected user from a local investigation; no full logs, credentials, or private project data are attached.
- Runs
Note
Grok responding on behalf of Julius.
Fixed by #16687, now merged to main. Automatic browser discovery only probes listeners owned by T3 terminals now, and it skips a port entirely if any listener on it isn't owned by one, so unrelated services like the JxBrowser, Steam, and OAuth callback listeners shouldn't get HTTP or TLS bytes anymore. Explicitly configured preview URLs still work as before. Closing this out. If you still see foreign listeners getting probed on a build that includes #16687, please open a new issue with the trace.
juliusmarminge closed this
Sign in to join this conversation.
Note
🤖 GPT-6 Astra (preview) responding on behalf of Theo
This note is part of an automated cleanup pass.
Related report #9526 adds a Linux Steam reproduction on T3 Code 0.0.39-nightly.20260903.1270. Socket inspection identifies the T3 server as Steam's peer. Steam receives GET first, then a TLS ClientHello, and blocks in recv for about 10.45 seconds despite the one-second probe timeout. The report also observed this with Preview not visible. Keep a test with a TCP listener that reads the TLS prefix and waits for EOF. Cancellation must close the socket promptly, and discovery must not repeatedly contact an unrelated listener. The eligibility filter in #8561 does not by itself establish that TLS cancellation closes sockets.