#477

Recover initial Steam connections across distinct CM servers

Openintraducinewants to merge intofrom

Steam sign-in could stop at the first WebSocket handshake failure and leave the failed task and session attached. A new connection now tries at most three distinct CM servers from Valve's directory, cleans up each failed transport, and preserves the last transport error when the server list is exhausted.

Adapted from kuscholar/iDeck at e3d845e, with credit retained in the code and documentation. Explicit certificate failures, offline errors and cancellation stop without retry. URLSession's certificate and hostname checks remain enabled. Errors retain only a known domain and numeric code. Additional guards prevent old messages, old disconnect callbacks and a delayed successful handshake from affecting a replacement or cancelled connection.

The change targets Madeira main's existing native Steam transport and requires no BCD or Playport port. The regression test also runs in CI.

Validation:

  • New deterministic host tests compile the production connection-loop and receive methods with scripted transports and the real CM server-selection code. They cover distinct endpoints, the three-attempt limit, cleanup, health reset, certificate rejection, cancellation, delayed success, replacement connections, stale messages and error redaction.
  • Existing Steam sign-in and library/download tests passed with AddressSanitizer; SteamSession pending-job tests passed.
  • All 100 production Swift files passed the iOS device-target type check.
  • Build reuse, component-cache keys, LLVM cache, clean bootstrap and app-link input checks passed.
  • git diff --check passed.

Live Steam, real TLS/VPN failures, device gameplay and a full IPA build were not tested.