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 <[email protected]>
Bots caught the emit-after-remove race: delegate callbacks deferred the
emit onto the serial queue then removed the emitter synchronously, so
close/error events never reached JS. Emits now run synchronously on the
queue before removal. Also cleans up activeSockets when connect throws,
and imports "expo" lazily so test import chains touching runtime.ts do
not evaluate expo's dev-only setup (CI __DEV__ failure).
Co-Authored-By: Claude Fable 5 <[email protected]>
React Native's iOS WebSocket is backed by SocketRocket, which never offers
permessage-deflate, so the server-side negotiation from #4705 only benefited
Android (OkHttp offers it by default). This adds a URLSessionWebSocketTask-
backed Expo module (URLSession offers the extension in its handshake) and
injects it as the Effect Socket constructor on iOS only, with a fallback to
the global WebSocket on Android and on binaries predating the module.
Co-Authored-By: Claude Fable 5 <[email protected]>