jupyter-server / pycrdt-websocket

WebSocket Connector for pycrdt
https://jupyter-server.github.io/pycrdt-websocket
MIT License
14 stars 10 forks source link

Offline work leaves ydocs in unsynced state #81

Closed Sinsho closed 2 weeks ago

Sinsho commented 1 month ago

Description

I'm using pycrdt-websocket in a Django application as a django channel consumer and y-websocket in a Vue application in the frontend as the client. The text editor used is Quill.

Up on connection from the client to the websocket I load the ydoc from the database in the overwritten method make_ydoc, then it gets synced (base behavior of the YjsConsumer).

Now I have following scenario:

  1. User A connects to the websocket
  2. User B connects to the websocket
  3. User A has an internet outage and keeps on editing in the Quill editor.
  4. User B keeps on editing (while being connected)
  5. User A reconnects to the websocket
  6. User A correctly gets their ydoc synced with the changes from User B
  7. However, User B does not get the changes from User A
  8. User A and B are left with different ydocs even though they share a room

Might the problem be that the sync command only syncs the ydoc in make_ydoc (loaded from the database) with the ydoc in the room and therefore doesn't have the changes from User A?

Is this intended behavior and if so is there some way in pycrdt-websocket to also force the ydoc in the room to get synced with the ydoc from the connecting user?

davidbrochart commented 1 month ago

Might the problem be that the sync command only syncs the ydoc in make_ydoc (loaded from the database) with the ydoc in the room and therefore doesn't have the changes from User A?

Difficult to say without a reproducible example.

Is this intended behavior and if so is there some way in pycrdt-websocket to also force the ydoc in the room to get synced with the ydoc from the connecting user?

No it's not the intended behavior, all connected users should be in sync.

Sinsho commented 2 weeks ago

I can't reproduce it on the current state of our project. The documents correctly get synced now on reconnection.

Therefore, I assume it was an error on our end. Thanks for the fast reply!