- Version: @libp2p/transport-websockets 10.1.12
- Platform: React Native (iOS + Android)
- Subsystem: transport-websockets
Severity:
High — dialing over the WebSocket transport fails on affected runtimes.
Description:
WebSocketMultiaddrConnection in @libp2p/transport-websockets reads bufferedAmount to manage backpressure. React Native's WebSocket declares the property but never assigns it (RN#33810) — so undefined < maxBufferedAmount is false, every write marks the stream as needing drain, drain is never emitted, and the noise handshake fails with a cryptic TypeError: Cannot read property 'message' of undefined from Upgrader._encryptOutbound.
#3497 proposed substituting 0 when bufferedAmount is missing, but that silently disables backpressure for affected connections:
canSendMore stays permanently true, writableNeedsDrain never flips, the muxer never pauses pushing data to streams
- Application code can pile unbounded bytes into the runtime's internal queue
- On Android, OkHttp closes the connection with code 1001 once its 16 MiB queue overflows (RN#56471)
Proposed resolution: detect missing bufferedAmount at construction in webSocketToMaConn and throw a typed error naming the limitation. Surfaces a clear dial-time error instead of the silent failure, without regressing backpressure.
Workaround today: @libp2p/transport-tcp works in React Native with react-native-tcp-socket + Metro polyfills — see the ipfs-shipyard demo.
Steps to reproduce the error:
- Set up a React Native (Expo) project using
@libp2p/transport-websockets with the standard noise + yamux stack.
- Dial a Node.js libp2p node listening on
/ip4/.../tcp/.../ws.
- Dial fails at
mss.select with TypeError: Cannot read property 'message' of undefined from Upgrader._encryptOutbound.
A working reproducer is described in #3497.
Severity:
High — dialing over the WebSocket transport fails on affected runtimes.
Description:
WebSocketMultiaddrConnectionin@libp2p/transport-websocketsreadsbufferedAmountto manage backpressure. React Native's WebSocket declares the property but never assigns it (RN#33810) — soundefined < maxBufferedAmountisfalse, every write marks the stream as needing drain, drain is never emitted, and the noise handshake fails with a crypticTypeError: Cannot read property 'message' of undefinedfromUpgrader._encryptOutbound.#3497 proposed substituting
0whenbufferedAmountis missing, but that silently disables backpressure for affected connections:canSendMorestays permanentlytrue,writableNeedsDrainnever flips, the muxer never pauses pushing data to streamsProposed resolution: detect missing
bufferedAmountat construction inwebSocketToMaConnand throw a typed error naming the limitation. Surfaces a clear dial-time error instead of the silent failure, without regressing backpressure.Workaround today:
@libp2p/transport-tcpworks in React Native withreact-native-tcp-socket+ Metro polyfills — see the ipfs-shipyard demo.Steps to reproduce the error:
@libp2p/transport-websocketswith the standard noise + yamux stack./ip4/.../tcp/.../ws.mss.selectwithTypeError: Cannot read property 'message' of undefinedfromUpgrader._encryptOutbound.A working reproducer is described in #3497.