Closed holtwick closed 3 years ago
Right. I duplicated that because the close handler is not called when the error
event is called. I should have combined that with the previous handler. Although I don't see how this can lead to issues?
After I removed the part completely my issues were gone. The problem was that peers
message was emitted, first to with payload telling to remove the peer and then afterwards another one that tried to add it again.
Maybe somewhere here? https://github.com/yjs/y-webrtc/blob/e0d5d11ec49de741b097f59283a0fb7fdf690899/src/y-webrtc.js#L267-L277
Maybe this is a misunderstanding. The intention is that y-webrtc automatically handles (and reconnects) connections unless you explicitly disconnect the provider instance (then no connection should be possible anymore).
So when the connection to a peer is closed, then it will automatically subscribe to find more peers again.
Whatever the reason was, your change fixed the issue. I had two browser windows being connected via y-webrtc and when reloading one of them the other one showed 2 connections. This is fixed now, probably due to the duplicate listening to 'close' being removed. Thanks!
Oh nice! It makes sense as I simply assumed the second handler would be called after the first one (which might not be the case). Then I will publish a new release of this package as it seems to fix an issue.
These lines seem to be wrong: https://github.com/yjs/y-webrtc/blob/master/src/y-webrtc.js#L222-L225
The result of it is, that peers are not removed correctly anymore.