We’re using YJS+Tiptap+Hocuspocus for our document editor, and everytime Hocuspocus detects that all websocket connections have dropped, we save the current Y.Doc binary to our database (and load it on cold start for the next connecting client).
This is working great! However, we’ve recently seen long running documents hit the 5MB+ Y.Doc size when their content is only 75KB or so.
I’d like to be able to clear out old history on cold start (loading the document when it hasn’t been edited for awhile). I know this can be achieved by creating a brand new Y.Doc from the original content without the history.
The challenge with this approach is that its possible that a client still exists (disconnected) with old in-memory state that contains the document updates that have now been deleted, which, when sent to the server, will result in that content being added to the doc.
Is there any way to instruct the server side document to reject updates that are before a certain time? Or if each update has a clock value, to reject updates before that clock value?
Also open to other approaches for keeping the document size down for long lived docs - This was the first one I thought of.
Thanks in advance!