My application is using YJS with IndexedDB + Postgres (via websocket) persistence and I have a client that lost all of his data.
I figured out that the client data was never written to Postgres because it never closed the application - so the websocket connection did not close neither, and the data was not written to Postgres.
It may or may not be useful, but the client is using Safari.
I have more troubles to figure out how its data was not saved locally with the IndexedDB provider. I looked at the code of
y-indexeddb and this is what I understand:
- whenever an update happens to a document, it is added to IndexedDB
- when the number of updates is greater than 500, all updates are merged into one big update
That seems pretty solid, and completely irrelevant to the fact that the client never closed the tab.
Could it happen that since the latest data has never been saved into Postgres, the Postgres data overwrote the local data when the client finally refreshed the page?
If a merge of all the updates then happened in IndexedDB, all previous data would be cleaned up even locally and could not be found again.