simple-peer icon indicating copy to clipboard operation
simple-peer copied to clipboard

Cannot read property 'sdp' of undefined in Brave

Open achingbrain opened this issue 5 years ago • 4 comments

This appears to be related to Brave blocking browser fingerprinting, but the promise returned from RTCPeerConnection.createOffer can resolve to undefined (and not throw) resulting in the following error:

AggregateError: Failed to connect to peer: 
    TypeError: connection error 127.0.0.1:13579: Cannot read property 'sdp' of undefined

If you disable Shields in Brave it works as expected.

I'm not sure what simple-peer can do about that, other than guard on offer being undefined, treat it as a failure case and throw an appropriate error.

Similar issue: https://github.com/webrtcHacks/adapter/issues/1028

achingbrain avatar Jul 09 '20 09:07 achingbrain

Well, if browser breaks standard APIs, I don't think library should do anything about it. Check what it breaks and make detection outside of simple-peer in your app. You'll want to show a nice message to the user anyway instead of breaking app in unexpected way.

nazar-pc avatar Jul 09 '20 13:07 nazar-pc

Well, if browser breaks standard APIs, I don't think library should do anything about it

You're correct that it's weird and nonstandard, and perhaps they shouldn't be doing it but part of the reason you use a library is to paper over the cracks in differences between implementations. I note there are already workarounds for other bad browser behaviour.

Check what it breaks and make detection outside of simple-peer in your app

The error occurs during the process of negotiating a connection. In order to make that detection you'd have to start negotiating a connection outside of simple-peer which means you're deep in WebRTC plumbing which sort of negates the point of using simple-peer in the first place.

achingbrain avatar Jul 09 '20 16:07 achingbrain

Has anyone filed an issue with brave? I understand the intention to limit the ip gathering but this solution is quite... harmful

fippo avatar Jul 13 '20 12:07 fippo

It seems to only happen when on an IP domain (e.g. 127.0.0.1). I've opened an issue with Brave.

t-mullen avatar Aug 09 '20 23:08 t-mullen