Device pairing always fails: core waits for a tunnel:registered event the backend never emits
Summary
Pairing a phone never completes: openhuman.devices_create_pairing fails with [devices/rpc] tunnel:register failed: [devices/tunnel] timeout waiting for tunnel:registered after a 10s hang. 100% of register attempts fail in production.
Problem
What happens: the core emits tunnel:register then waits for an inbound tunnel:registered Socket.IO event. The backend (tunnel relay) answers tunnel:register only via the Socket.IO ACK callback and never emits a tunnel:registered event, so the core always times out after 10s.
Root cause — cross-component Socket.IO contract mismatch:
- Backend
tunnel:registerhandler replies withack({channelId, pairingToken, pairingExpiresAt})and emits notunnel:registeredevent. The ack carries nosessionToken. - Core's
SocketManager.emitsends a raw event frame with no ack id, and the WS read loop has no Socket.IO ACK arm, so the backend's ack reply is silently dropped. - Core's
TunnelRegisterResponseadditionally expects asessionTokenthe backend never mints for thecorerole (the session token is minted for the client during pairing).
Impact: device/QR pairing (experimental iOS client) is fully broken. Telemetry: 442 events / 36 affected users, first seen 2026-06-18, across app versions 0.57.44 → 0.58.0, production, macOS.
Repro: Settings → Pair phone → register hangs ~10s → error. Reproduces on current main (mismatch present on both sides of main).
Solution (proposed)
Fix the core side to speak the ack the backend already uses:
- Add generic Socket.IO ACK support to
SocketManager(emit_with_ack) + an ACK arm in the WS read loop, guarded by anis_connected()fast-fail. - Rewrite
tunnel_client::emit_registerto use the ack; alignTunnelRegisterResponseto{channelId, pairingToken, pairingExpiresAt}(drop the phantomsessionToken). - Tokenless
tunnel:connectforrole:core; remove the now-deadtunnel:registeredevent plumbing.
No backend change required.
Acceptance criteria
- [ ] Repro gone — pairing register completes and returns a channel/QR instead of timing out.
- [ ] Regression safety — unit tests couple the core parser to the backend ack shape (ack parse + register parse) so a future drift fails CI; not-connected path fast-fails.
- [ ] Diff coverage ≥ 80% — fix PR meets the changed-lines gate.
- [ ] Pairing manually verified on
mainagainst staging.
Related
Sentry: TAURI-RUST-EVC (tauri-rust) Backend tunnel relay: tinyhumansai/backend#709 Core pairing flow: #3452
Duplicate of #4355 ("fix(devices): use socket ack for pairing register"), merged 2026-06-30, shipped in v0.58.7. #4355 is the exact fix: SocketManager::emit_with_ack + Socket.IO ACK read arm; tunnel:register reads ack shape {channelId, pairingToken, pairingExpiresAt}; tokenless role:core connect; phantom sessionToken dropped. Sentry TAURI-RUST-EVC flipped resolvedInNextRelease.
This issue is not resolved. I am getting this error when I try to pair my IPhone on openhuman v0.63.12.