Problem with WebrtcProvider connect after disconnect

I am trying the y-codemirror demo on my local machine, and I changed the code to use a WebrtcProvider, basically this is my change,

-  const provider = new WebsocketProvider(
-    'wss://demos.yjs.dev',
-    'codemirror-large',
+  const provider = new WebrtcProvider(
+    'test-doc',
     ydoc
   )

I open the shared doc in both Chrome and Safari, when I disconnect from Safari and reconnect, Chrome can not get Safari’s change, but Safari can get Chrome’s change, now the change is only flowing from Chrome to Safari. I have to reload the Safari page to make it sync again.

If I disconnect and reconnect from Chrome instead, the change is only flowing from Safari to Chrome.

Is this a bug? I’m using the latest y-webrtc master, commit id d9f2b28b2ab28edfc11a0b0b48f3bc0a5919f8bf

Hi @yufw,

Thanks for reporting. WebRTC is unfortunately still not very well supported. There are inconsistencies between browsers and some have trouble connecting to each other.

I created a ticket for this issue: https://github.com/yjs/y-webrtc/issues/19

This is definitely a bug. I saw similar, but it is good to know that you can reproduce the issue by simply disconnecting and reconnecting.

Tbh, I don’t have time right now to look into this. Maybe someone else might be willing to debug a bit. I’d be happy to help figuring out the underlying issues after seeing some logs.

@dmonad Thanks! I found another issue with WebsocketProvider, not sure if I should start a new topic, the issue can be reproduced in a similar way.

When I disconnect and reconnect from one end, the other end does not render the remote cursor, Reloading the page of the reconnected side makes the remote cursor appear again in the other side. The issue is only remote cursor, changes are always in sync.

I tested it using Safari & Chrome and also Firefox & Chrome and I used the official demo, https://demos.yjs.dev/codemirror/codemirror.html

Oh interesting… Thanks for reporting, I can reproduce the issue even without safari. This seems like a bug.

I opened another more generic issue here: https://github.com/yjs/yjs/issues/258

You can follow it and get notified when the issue has been fixed.