How to use Y.PermanentUserData?

hello everyone,

I am building a collaborative editor based on prosemirror and yjs without y-websocket (https://github.com/yjs/y-websocket/blob/master/src/y-websocket.js).

On the server side, i have integrated a java server which just broadcast update from all clients and in charge of data persistence, and a node RPC server which has some pure functions to generate encodedState or stateVector based on empty ydoc and updates which comes from the java server.

this works nicely except for versions, if i use Y.PermanentUserData in client side as the prosemirror version demo:


clients cannot sync each other anymore, now i have checked the discuss here: Sync protocol over websockets. seems the problem comes from that the whole document is not synced before update broadcast due to each client has it’s own userMapping by add Y.PermanentUserData.

so i dive into the https://github.com/yjs/yjs-demos/blob/master/prosemirror-versions/prosemirror-versions.js, and try sync the whole document according to the syncStep1 and syncStep2. however i still cannot sync clients…

is there any potential risk base on my server solution or is the sharedDoc of the wsProvider on the server side necessary ? how can i sync each client’s permanentUserData base on the server that only broadcast updates and rpc the pure node server to data persistence

You are probably not broadcasting the local state to the other clients. If there are missing updates from one client, newer updates can’t be applied. Try broadcasting the local state after an initial connection.