openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Embedded core cannot start on Windows when port 7788 is in an OS-excluded range, because the fallback ports 7789-7798 are in the same range

Open senamakel opened this issue 3 weeks ago • 2 comments

Milestone: Nov 9 - Nov 13 · Parent: tinyhumansai/team#46

Sentry issues covered

2 Sentry issue(s), 300 events in total, up to 1 users on a single issue. Releases seen: 0.64.15.

Sentry Project Events Users Releases Last seen
TAURI-RUST-8CB tauri-rust 297 1 0.64.15 2026-11-01
TAURI-RUST-16V1 tauri-rust 3 1 0.64.15 2026-11-03

What happens

On Windows, Hyper-V / WinNAT / WSL2 / Docker reserve TCP port blocks (netsh interface ipv4 show excludedportrange). Binding 127.0.0.1:7788 fails with WSAEACCES (os error 10013). pick_listen_port_with_policy correctly treats this as an exclusion and tries the fallback pool, but the pool is 7789-7798, the ten ports right next to 7788. Reserved blocks are usually 50-100 ports wide, so the whole pool is excluded too, and the core gives up: "preferred core port 7788 is occupied by port excluded by OS (...); no fallback ports available in [7789..7798]". The app then has no core. TAURI-RUST-8CB: 297 events on 0.64.15 (one user keeps retrying); 16V1 is a second machine.

Likely code path

  • crates/openhuman-core/src/platform/connectivity/rpc.rs: DEFAULT_FALLBACK_START = 7789, DEFAULT_FALLBACK_END = 7798; pick_listen_port_for_host_with builds the pool; pick_listen_port_with_policy routes 10013 to pick_fallback_port; pick_fallback_port returns NoAvailablePort after the contiguous pool
  • crates/openhuman-app/src/core_process.rs: start-up path that reports the bind failure

Suggested fix

  • When the preferred port is OS-excluded (or the contiguous pool is exhausted), fall back to an OS-assigned port (bind(127.0.0.1:0)) and publish it through the existing ready signal (EmbeddedReadySignal.port / fallback_from), which the shell already honours.
  • Alternatively add a second pool far from 7788 (different 100-port block), but port 0 is the only choice that cannot collide with an exclusion.
  • Regression test: inject a binder that returns 10013 for 7788..=7798 and assert a port is still picked.

Done when

  • [ ] A regression test reproduces the failure (or the misreport) and passes with the fix
  • [ ] The fix is merged to main
  • [ ] The Sentry issues above are resolved in the next release, and stay quiet on builds that carry the fix

senamakel avatar Nov 09 '26 13:11 senamakel

On Windows, the embedded core fails to start when the preferred port 7788 lies in an OS-reserved TCP exclusion range, because the fallback pool 7789-7798 sits immediately adjacent and is typically inside the same 50-100 port reserved block; the core then reports no available fallback port and the app gets no core. Suggested fix is falling back to an OS-assigned port (bind :0) published through the existing ready signal, plus a regression test injecting 10013 for 7788..=7798. Close to zero user impact (2 Sentry issues, ~1-2 users) but a hard start-up failure on affected Windows/Hyper-V machines with no workaround for those users, so p1; no candidate issue covers this port-exclusion failure, so no prior art.

Labelled priority: p1.

tinysweeper avatar Nov 09 '26 13:11 tinysweeper