Hello.
I am creating a whiteboard tool using a combination of tldraw and yjs.
I am using postgres for persistence on the server, but on rare occasions I am unable to restore the document. (It worked as expected during client synchronization, but once everyone disconnected and tried to connect again, it only restored halfway through.)
Upon closer inspection, I’m beginning to think that the contents of the pendingStructs are bloated and that data may be missing.
Is it possible to forcefully compensate for the corrupted data?
Also, is the possibility of corruption more likely due to an insert failure?
Is there anything that could go wrong if the data is too large?
You probably need to identify steps to reproduce before anything useful can be said about it. Unfortunately that’s easier said than done if it is intermittent.
Any logging you can add to help get more clues when it does go wrong could be helpful.
What provider do you use to communicate updates to the server? y-websocket?
Do you save the state vector on the server after updates are successfully persisted? Maybe the state vector is being saved without a full confirmation that the update is saved.
This is the expected behavior of yjs. You must lose one update when syncing the server and client data. This will cause ALL following updates to be ignored and put into pendingStructs.
I made utils to inspect if an update will cause pending struct a few months ago.