From 926ff9baaa8cbef2ce5b6189feafbdcde046dd25 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Tue, 28 Jul 2026 16:53:29 -0700 Subject: [PATCH] fix(mobile): bypass injected URLProtocol classes on iOS websockets Verified on the simulator: the socket completed its 101 (with permessage-deflate negotiated) and then died instantly with NSURLErrorDomain -1005, so JS never saw an open event and the supervisor reconnected every 15s. The dev client registers custom URLProtocol classes for its network inspector; they intercept URLSession traffic and do not understand the WebSocket upgrade. Clearing protocolClasses on the session config fixes it: one stable socket, no reconnects over 60s. Co-Authored-By: Claude Fable 5 --- .../t3-websocket/ios/T3WebSocketModule.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/mobile/modules/t3-websocket/ios/T3WebSocketModule.swift b/apps/mobile/modules/t3-websocket/ios/T3WebSocketModule.swift index 1a5ae9cde6..cb975a665c 100644 --- a/apps/mobile/modules/t3-websocket/ios/T3WebSocketModule.swift +++ b/apps/mobile/modules/t3-websocket/ios/T3WebSocketModule.swift @@ -58,11 +58,15 @@ private final class T3WebSocketConnections: NSObject, URLSessionWebSocketDelegat private var idsByTaskIdentifier: [Int: Int] = [:] private var emittersById: [Int: T3WebSocketEmitter] = [:] - private lazy var session = URLSession( - configuration: .default, - delegate: self, - delegateQueue: nil - ) + private lazy var session: URLSession = { + let configuration = URLSessionConfiguration.default + // Dev clients (and network debuggers) register custom URLProtocol classes + // that intercept URLSession traffic. They do not understand the WebSocket + // upgrade and drop the connection right after the 101 (NSURLErrorDomain + // -1005). WebSocket traffic has no reason to go through them. + configuration.protocolClasses = [] + return URLSession(configuration: configuration, delegate: self, delegateQueue: nil) + }() func open(id: Int, url: URL, protocols: [String], emitter: @escaping T3WebSocketEmitter) { queue.async {