close() during CONNECTING (an Effect open-timeout or scope teardown) leaves
the native connect in flight, so its didOpen could still land and flip the
socket back to OPEN, firing open handlers on a socket the caller had already
given up on. handleOpen now only transitions from CONNECTING.
Co-Authored-By: Claude Fable 5 <[email protected]>
URLSession retains its delegate until invalidated, so cancelAll() left the
connections object and its session alive on every module destroy/recreate
cycle. Teardown now invalidates and clears the session; the next open()
builds a fresh one.
Verified on the simulator: environment connects, holds a single socket for
60s, and reconnects cleanly after a full app teardown and relaunch.
Co-Authored-By: Claude Fable 5 <[email protected]>
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]>