peer.addTrack(), peer.addStream() throwing error when adding the user's displayMedia to an existing peer stream(camera and mic stream).
- Dominant language
- JavaScript
- Stars
- 7.8k
- Forks
- 983
- PR merge metrics
- No merged PRs in 30d
Description
**What version of this package are you using?**
9.11.0
**What operating system, Node.js, and npm version?**
Windows 10
Node version - 14.16.0
npm version - 6.14.11
**What happened?**
I created a mesh network of peers and passed the users' video and audio streams as the stream when establishing the connection. When I tried to add the user's navigator.mediaDevices.getDisplayMedia() stream to the existing peer, the peer connection gets destroyed and the following error stack is observed:

the same peer signaling method was working fine when I used it for establishing the peer connection. However, this error is observed when I try to add the new Stream or add a new Track to the existing stream which was passed when creating the peer.
```
// initiator peer
const peer1 = new Peer({
initiator:true,
trickle: false,
stream1 /* stream is a state variable containing a MediaStream object with the user's video and audio stream */
});
const peer2 = new Peer({
initiator:false,
trickle: false,
stream2 /* stream is a state variable containing a MediaStream object with the user's video and audio stream */
});
//both peers got their respective streams. the signals were exchanged via socket.io
//adding screen stream/ track
navigator.mediaDevices.getDisplayMedia({cursor:true}).then(str =>{
let track = str.getTracks()[0] // only has one track
peer1.addTrack(track , stream1);
/* tried adding a stream as well and observed the same error
peer1.addStream(str);
});
```
**What did you expect to happen?**
The expectation was to still have the peer connection established with the new streams/tracks being provided to the users.
**Are you willing to submit a pull request to fix this bug?**
No.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.