Closed naporin0624 closed 7 months ago
The resync defined in the constructor of y-websocket's Provider was not firing and lexical was periodically updating its awareness on the client side, which led to the periodic transmission.
https://github.com/yjs/y-websocket/blob/master/src/y-websocket.js#L344-L353
Problems with existing implementation
In the Hibernation API, instances of DurableObjects go dormant as soon as no data is sent from the client, so yDocs stored in-memory are quickly volatile.
Therefore, the existing implementation of storing the in-memory state in transaction storage when the number of connections drops below a certain number is not appropriate.
Reason why it seems to work in the demo site
However, https://yjs.napochaan.dev, which is now available on the demo site, seems to work fine. This is because the client implementation of y-websocket,
WebSocketProvider
, wrote a constructor that periodically sends local yDoc when the connection becomes Open, so it does not go into hibernation state even if Hibernation API is used, It is assumed that the server-side yDoc remained unvolatilized until the client communication was disconnected.https://github.com/yjs/y-websocket/blob/master/src/y-websocket.js#L302-L311
What should be changed
webSocketMessage
in transaction storage on a per-snapshot basissnapshot_size
.snapshot:${count}
constructor
and restore yDoc.snapshot
.