[Sailfish/web] Tailscale pairing fails: web build disables the Relay fallback, and the direct path depends on a wide desktop bind that several offer paths never widen #7

Open
opened 2026-09-26 12:26:41 +02:00 by Grok · 0 comments
Collaborator

Symptom

Pairing the Orca phone app (SailfishOS) to a desktop over Tailscale fails. The phone shows
"Connecting… / Couldn't connect within 25s" (or "direct and relay pairing paths both failed")
even though both devices are on the same tailnet and the desktop's Tailscale address is
correctly advertised in the pairing code.

Repro (from the SailfishOS phone, orca launcher → sailfish-browser web bundle):

  1. Desktop (fresh GUI launch, or mobile:getRuntimePairingUrl) generates a pairing code
    advertising its Tailscale address, e.g. wss://100.88.248.5:<port>.
  2. Phone scans/pastes it and hits Pair.
  3. The direct Tailscale dial never authenticates; no relay is attempted; pairing never completes.

Root cause (two interacting defects)

1. The web build hard-disables the Relay path

mobile/src/transport/pre-profile-pairing-coordinator.ts:148

if (offer.relay && dependencies.platform !== 'web') {
  journal = createMobileRelayPairingJournal({ ...offer, relay: offer.relay }, hostId, hostName, now)
  await dependencies.saveJournal(journal)
}
// → on 'web', journal stays null, so only the direct candidate exists:
const candidates = [{ path: 'direct', client: directClient }]

On platform === 'web' (which is exactly the SailfishOS build — it ships the Expo web
bundle, not the native iOS/Android target) the relay journal is never created, so
racePairingCandidates runs only the direct dial. Relay is the one path designed to work
when the direct endpoint is unreachable; the phone cannot use it at all.

2. The direct path depends on a wide desktop bind that several offer paths never perform

The desktop runtime binds loopback by default (runtime-rpc-lifecycle.ts: resolveInitialWebSocketBindHost() → 127.0.0.1 when exposeNetworkByDefault is false and no
network device has connected). It only widens to 0.0.0.0 via ensureNetworkExposure().

  • mobile:getPairingQR → createMobilePairingOffer does call ensureNetworkExposure() (good).
  • mobile:getRuntimePairingUrl widens only when !servesThisComputerOnly(reach, ip).
  • createPairingOffer (the base mint, used by orca serve/CLI) never calls
    ensureNetworkExposure(); it only rewrites the bound endpoint's hostname via
    resolveAdvertisedPairingEndpoint (runtime-rpc-pairing.ts:160).

So whenever a pairing offer is minted on a fresh desktop through a path that does not widen,
the advertised wss://<tailnet>:<port> has no listener on the tailnet (the socket is on
127.0.0.1). The phone's sole remaining candidate (direct) gets connection-refused/timeout, and —
because of (1) — there is no relay to recover. Result: Tailscale pairing simply cannot complete
on the phone.

Proposed fixes

  1. Enable the Relay path in the web build (remove or narrow the
    platform !== 'web' guard in pre-profile-pairing-coordinator.ts), or add a web-safe relay
    transport. This alone makes remote/tailnet pairing robust (relay works without a wide bind).
  2. Make createPairingOffer advertise a reachable endpoint: either call
    ensureNetworkExposure() before minting (like the QR path does) or, when the resolved
    advertised hostname is a tailnet/LAN address and the current bind is loopback, fail closed
    with network_exposure_failed guidance instead of minting a dead endpoint.
  3. (Surface) On the phone, when only the direct path is available and it fails, show the
    Tailscale hint from withRemoteRuntimeTailscaleHint so the user isn't left with a bare timeout.

Files involved

  • mobile/src/transport/pre-profile-pairing-coordinator.ts (web relay-skip)
  • mobile/src/transport/pairing-candidate-race.ts (direct/relay race)
  • src/main/runtime/runtime-rpc/runtime-rpc-lifecycle.ts (resolveInitialWebSocketBindHost)
  • src/main/runtime/runtime-rpc/runtime-rpc-network-exposure.ts (ensureNetworkExposure/widenWebSocketBind)
  • src/main/runtime/runtime-rpc/runtime-rpc-pairing.ts (createPairingOffer)
  • src/main/ipc/mobile.ts (mobile:getPairingQR / mobile:getRuntimePairingUrl)
  • src/main/runtime/pairing-endpoint.ts (resolveAdvertisedPairingEndpoint)

Notes

  • Related to open issue #6 (Sailfish blank screen over file:// → HTTP workaround); this is the
    next failure once the app actually launches.
  • The desktop "pair phone" QR path works when it widens; the failure is specifically the
    direct-only + non-widening combination on the web/phone side.
## Symptom Pairing the Orca phone app (SailfishOS) to a desktop over **Tailscale** fails. The phone shows "Connecting… / Couldn't connect within 25s" (or "direct and relay pairing paths both failed") even though both devices are on the same tailnet and the desktop's Tailscale address is correctly advertised in the pairing code. Repro (from the SailfishOS phone, `orca` launcher → sailfish-browser web bundle): 1. Desktop (fresh GUI launch, or `mobile:getRuntimePairingUrl`) generates a pairing code advertising its Tailscale address, e.g. `wss://100.88.248.5:<port>`. 2. Phone scans/pastes it and hits Pair. 3. The direct Tailscale dial never authenticates; no relay is attempted; pairing never completes. ## Root cause (two interacting defects) ### 1. The web build hard-disables the Relay path `mobile/src/transport/pre-profile-pairing-coordinator.ts:148` ```ts if (offer.relay && dependencies.platform !== 'web') { journal = createMobileRelayPairingJournal({ ...offer, relay: offer.relay }, hostId, hostName, now) await dependencies.saveJournal(journal) } // → on 'web', journal stays null, so only the direct candidate exists: const candidates = [{ path: 'direct', client: directClient }] ``` On `platform === 'web'` (which is exactly the SailfishOS build — it ships the Expo **web** bundle, not the native iOS/Android target) the relay journal is never created, so `racePairingCandidates` runs **only** the direct dial. Relay is the one path designed to work when the direct endpoint is unreachable; the phone cannot use it at all. ### 2. The direct path depends on a wide desktop bind that several offer paths never perform The desktop runtime binds **loopback by default** (`runtime-rpc-lifecycle.ts: resolveInitialWebSocketBindHost()` → `127.0.0.1` when `exposeNetworkByDefault` is false and no network device has connected). It only widens to `0.0.0.0` via `ensureNetworkExposure()`. - `mobile:getPairingQR` → `createMobilePairingOffer` **does** call `ensureNetworkExposure()` (good). - `mobile:getRuntimePairingUrl` widens **only** when `!servesThisComputerOnly(reach, ip)`. - `createPairingOffer` (the base mint, used by `orca serve`/CLI) **never** calls `ensureNetworkExposure()`; it only rewrites the bound endpoint's hostname via `resolveAdvertisedPairingEndpoint` (`runtime-rpc-pairing.ts:160`). So whenever a pairing offer is minted on a fresh desktop through a path that does not widen, the advertised `wss://<tailnet>:<port>` has **no listener on the tailnet** (the socket is on 127.0.0.1). The phone's sole remaining candidate (direct) gets connection-refused/timeout, and — because of (1) — there is no relay to recover. Result: Tailscale pairing simply cannot complete on the phone. ## Proposed fixes 1. **Enable the Relay path in the web build** (remove or narrow the `platform !== 'web'` guard in `pre-profile-pairing-coordinator.ts`), or add a web-safe relay transport. This alone makes remote/tailnet pairing robust (relay works without a wide bind). 2. **Make `createPairingOffer` advertise a reachable endpoint**: either call `ensureNetworkExposure()` before minting (like the QR path does) or, when the resolved advertised hostname is a tailnet/LAN address and the current bind is loopback, fail closed with `network_exposure_failed` guidance instead of minting a dead endpoint. 3. (Surface) On the phone, when only the direct path is available and it fails, show the Tailscale hint from `withRemoteRuntimeTailscaleHint` so the user isn't left with a bare timeout. ## Files involved - `mobile/src/transport/pre-profile-pairing-coordinator.ts` (web relay-skip) - `mobile/src/transport/pairing-candidate-race.ts` (direct/relay race) - `src/main/runtime/runtime-rpc/runtime-rpc-lifecycle.ts` (`resolveInitialWebSocketBindHost`) - `src/main/runtime/runtime-rpc/runtime-rpc-network-exposure.ts` (`ensureNetworkExposure`/`widenWebSocketBind`) - `src/main/runtime/runtime-rpc/runtime-rpc-pairing.ts` (`createPairingOffer`) - `src/main/ipc/mobile.ts` (`mobile:getPairingQR` / `mobile:getRuntimePairingUrl`) - `src/main/runtime/pairing-endpoint.ts` (`resolveAdvertisedPairingEndpoint`) ## Notes - Related to open issue #6 (Sailfish blank screen over file:// → HTTP workaround); this is the *next* failure once the app actually launches. - The desktop "pair phone" QR path works when it widens; the failure is specifically the direct-only + non-widening combination on the web/phone side.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
donach/orca#7
No description provided.