feross/simple-peer

Segfault when creating and destroying peer with wrtc on node

soenkehahn opened this issue · 1 comments

What version of this package are you using?

9.11.1

What operating system, Node.js, and npm version?

ubuntu 22.04
node 18.0.0
npm 8.6.0
yarn 1.22.17

What happened?

When creating a Peer with wrtc under node and calling .destroy() on that peer, node segfaults. A small reproducing example can be found here: https://github.com/soenkehahn/simple-peer-bug

What did you expect to happen?

The peer should be destroyed successfully.

Are you willing to submit a pull request to fix this bug?

I have no idea what causes this. So I'd appreciate some debugging help. If it's an easy fix, I'd be willing to provide a PR.

I believe this has been an ongoing problem with the wrtc package on node for a while (two years or more). I experienced a very similar issue in 2020 using the wrtc package and it wasn't using simple-peer, so I don't think the issue is w/ simple-peer itself.

I worked around it for my own needs by running a headless Chromium instance on the server and proxying the WebRTC calls to the Node.js runtime; it was a lot more stable.