-
-
Couldn't load subscription status.
- Fork 990
Description
What version of this package are you using?
9.11.1
What operating system, Node.js, and npm version?
iOS 18.6.2 / idk, n/a afaik but can get it if needed
What happened?
Attempting to connect two React Native peers correctly signals, but SimplePeer never emits a connect. (The underlying RTCPeerConnection does transition to a connected connectionState.)
Debugging, I saw that getStats took the non-_isReactNativeWebrtc branch because _isReactNativeWebrtc was false, despite running on a RN platform. To be sure, I executed getStats in console and got a Promise back – so it's a bug that we didn't take the promise-based getStats branch.
_isReactNativeWebrtc checks _peerConnectionId:
Line 109 in f1a492d
| this._isReactNativeWebrtc = typeof this._pc._peerConnectionId === 'number' |
RTCPeerConnection a few years ago (replaced by _pcId) – so the current check on typeof resolves to 'undefined'.
This would be fixed by either (or both of):
- Change
_isReactNativeWebrtcto checktypeof _pcId - Allow the caller to pass in
isReactNativeWebrtcin theSimplePeerconstructor opts – more work for caller, but avoids getting stuck with this kind of breakage in the future, as_pcIdis a heuristic and not a stable API
I patched in (2) in my local dependency to unblock myself, and it appears to work.
Sorry to mess with the PR template – it just seems like the bug is apparent from the source. I can be more formal if it's really needed.
Are you willing to submit a pull request to fix this bug?
Yes