_isReactNativeWebrtc not compatible with latest react-native-webrtc, causing failure to connect on React Native

Author: davidisaacleeCreated Oct 12, 2025Updated Oct 12, 2025

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: https://github.com/feross/simple-peer/blob/f1a492d1999ce727fa87193ebdea20ac89c1fc6d/index.js#L109 which was removed from react-native-webrtc's 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):

  1. Change _isReactNativeWebrtc to check typeof _pcId
  2. Allow the caller to pass in isReactNativeWebrtc in the SimplePeer constructor opts – more work for caller, but avoids getting stuck with this kind of breakage in the future, as _pcId is 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