Skip to content

fix(desktop): keep the advertised LAN host in sync with the current network - #67

Merged
enisze merged 1 commit into
mainfrom
feature/fix-mobile-app-store-error
Aug 28, 2026
Merged

fix(desktop): keep the advertised LAN host in sync with the current network#67
enisze merged 1 commit into
mainfrom
feature/fix-mobile-app-store-error

Conversation

@enisze

@enisze enisze commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Problem

Pairing a phone from the store build failed with:

Failed to fetch remote environment endpoint http://192.168.2.37:3773/.well-known/t3/environment (HttpClientError: Transport error)

The desktop resolves its LAN address once, during startup (configureFromSettings), and stores it in the exposure runtime state. Every later read — the Connections settings row, the pairing link, the QR code, the advertised-endpoint list — returned that stored string until the app relaunched.

In the reported case the desktop had been running for three days and had bootstrapped with endpointUrl: http://192.168.2.37:3773, while the machine had since moved to 192.168.1.21. The backend was bound to 0.0.0.0 and reachable at the new address the entire time; only the advertised host was stale, so the QR sent the phone to an IP nobody answers on.

Fix

Re-resolve the advertised host from the live interface list on every getState / getAdvertisedEndpoints call, reusing the existing resolveLanAdvertisedHost picker (so the T3CODE_DESKTOP_LAN_HOST override still wins).

  • bindHost, localHttpUrl, and port are deliberately left untouched — picking up a new address never triggers a backend relaunch.
  • A local-only run advertises nothing, including one that fell back to local-only for want of an address at boot: that run bound loopback only, so advertising an address that appeared later would point clients at a socket the process never listens on.

Tests

Two regression tests in DesktopServerExposure.test.ts:

  • a machine that roams to another network mid-run — advertised host, endpoint URL, and endpoint list all follow it, while bind host and loopback URL stay put;
  • a network-accessible request that fell back to local-only stays unadvertised when a LAN address shows up afterwards.

vp test run src/backend/DesktopServerExposure.test.ts → 11/11 pass, and the roaming test fails without the fix (Expected: "192.168.1.21" / Received: "192.168.2.37"). Lint and format clean.

🤖 Generated with Claude Code

…etwork

The desktop resolved its LAN address once during startup and cached it in the
exposure runtime state, so a machine that moved networks (or renewed its DHCP
lease) kept handing pairing links and QR codes the address it had at launch.
Phones then couldn't reach the backend even though it had been bound to every
interface the whole time.

Re-resolve the advertised host on every exposure-state and advertised-endpoint
read. The bind host, loopback URL, and port stay untouched, so picking up a new
address never needs a backend relaunch. A local-only run — including one that
fell back for want of an address — still advertises nothing, since it only
listens on loopback until the next relaunch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@enisze
enisze merged commit ddea1e4 into main Aug 28, 2026
@enisze
enisze deleted the feature/fix-mobile-app-store-error branch August 28, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant