yjs / y-indexeddb

IndexedDB database adapter for Yjs
https://docs.yjs.dev/ecosystem/database-provider/y-indexeddb
Other
196 stars 30 forks source link

init ydoc from indexeddb failed #18

Closed LeeSanity closed 2 years ago

LeeSanity commented 2 years ago

Describe the bug I'm using this project to add offline support for our preject, everything looks fine, but sometimes the initialization from local indexeddb will fail, it looks like that the initial gc process failed, but I'm not sure, and I haven't look deep into the codebase, any information will be very appreciated.

To Reproduce it happens occasionally

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image image

Environment Information

dmonad commented 2 years ago

Hi @LeeSanity,

Unfortunately, I can't debug this. As far as I know, you are the only one that experiences this error.

You could help me by extracting the document update(s) from the indexeddb database. If the content is not sensitive, simply post the entries of your document here, or send them to my mail address.

An obvious source of the error is that you are using two different versions of Yjs. Can you please check your package-lock whether that is the case? Newer versions of Yjs even throw a warning message when you use two different versions.

Cheers, Kevin

LeeSanity commented 2 years ago

thanks for your reply @dmonad, I have confirmed that we use yjs@13.5.24 in both the frontend & backend,

Some more information about our usage: we use tiptap (included y-prosemirror@1.0.14), y-indexeddb@9.0.7 in our frontend project, and in backend we use y-websocket for collaboration & database persistence

According to your needs, I just extracted two debug samples, as they are a little too big, so send to your email.

LeeSanity commented 2 years ago

More information about this issue, I have tried to close gc function for the ydoc, then other serious issue came out. and the ydoc in local indexeddb seems never updated whatever I do, meanwhile on the server side, everything looks fine. image

dmonad commented 2 years ago

You are clearly using a custom y-indexeddb extensions, as the updates you sent me use v2 encoding (upstream y-indexeddb still uses v1 encoding). The second "bug" you sent me is not related to Yjs, but rather to an infinite loop produced by your vue application.

I'm sorry, but I don't want to debug custom code for free. Feel free to contact me directly again if you want to pay for a 1on1 session so we can debug your code together.

LeeSanity commented 2 years ago

Ok, thanks a lot @dmonad

LeeSanity commented 2 years ago

One more information @dmonad : in yjs@13.5.24, Y.encodeStateAsUpdate just is using V2 encoding image

so, y-indexeddb use this v2 encoding defaultly.

dmonad commented 2 years ago

The third parameter specifies that we want to use the V1 encoder. It is all working as intended. y-indexeddb only uses the v1 encoder.