ueberdosis / hocuspocus

The CRDT Yjs WebSocket backend for conflict-free real-time collaboration in your app.
https://tiptap.dev/docs/hocuspocus/introduction
MIT License
1.29k stars 125 forks source link

Provider downloads document content twice when syncing initially #768

Closed aonnikov closed 9 months ago

aonnikov commented 10 months ago

Description

I see something weird in websocket messages between client and server. When syncing the document after connect, the server sends the same document content twice. It is something that is specific to Hocuspocus protocol? I don't see this for raw y-websocket, it sends content only once. When the document is large, this significantly increases time to sync.

I'm experimenting on live example here: https://templates.tiptap.dev/N9HkNRCwhN Here is an example of messages between client and server. Two highlighted incoming messages contain identical document content.

Screenshot 2023-12-29 at 13 48 04

Can someone explain, if it is expected and what is the need of sending it twice?

Steps to reproduce the bug Steps to reproduce the behavior:

  1. Go to https://templates.tiptap.dev/N9HkNRCwhN
  2. Open Network tab in developer tools in the browser
  3. Find websocket connection to the collaboration server and open details
  4. See document content received twice

Expected behavior I would expect the full document content to be sent only once. Increasing amount of data transferred between server and client increases response time and affects user experience.

Screenshot, video, or GIF See above.

Environment?

janthurau commented 9 months ago

thanks for the report! This will be fixed in the next release (this week).