An event when documents have synced

@micrology Nigel
Sun, 28 Sep 2025 08:24:30 +0000

I have a yjs client and a web socket provider with persistence. When a new client connects to a room, the client’s document merges with the version on the websocket server. I need to know (e.g. by observing an event) when the client version and the server version have completed merging and are now identical. The WSProvider event called ‘sync’ does not do this - it merely notes when the connection has been established.

I am currently using code such as

yMap.observe((evt) => { ... process the incoming changed key/values })

and

doc.transact(() => {yMap.set(... set key/map values...)})

as the interface to yjs. I am not using Y.encodeStateAsUpdate or Y.applyUpdate.

My documents can be up to 5 MB and so transmission and merging will not be instantaneous. I am surprised that I can’t find an event to do this in the documentation. Am I missing something obvious?