y-protocols
y-protocols copied to clipboard
When yjs clientId changed by the yjs library, the awareness crash
I encountered crash here:
TypeError: Cannot read properties of undefined (reading 'clock')
https://github.com/yjs/y-protocols/blob/e7da0a137d386ae2d2db63aed9794028ce1328ef/awareness.js#L201
seems right after this happened: https://github.com/yjs/yjs/blob/9f1548204ac8a5960c3112f96de4c962bbd264e8/src/utils/Transaction.js#L334
the yjs library may change clientId, but the awareness is not ready for that.
I also encounter this error regularly. I tried this simple solution:
const clientMeta= /** @type {MetaClientState} */ (awareness.meta.get(clientID))
if (!clientMeta) continue;
const clock = clientMeta.clock;
But it actually doesnt really solve the problem. The error itself is solved, but it leads to the problem that the client is out of sync afterwards.
Also have this issue in regards to https://github.com/facebook/lexical and yjs.
I'm not entirely sure about the internals of YJS; why does the client ID change happen in the first place?
Same here