y-protocols icon indicating copy to clipboard operation
y-protocols copied to clipboard

When yjs clientId changed by the yjs library, the awareness crash

Open ulion opened this issue 3 years ago • 3 comments

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.

ulion avatar Mar 14 '22 05:03 ulion

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.

MaxNoetzold avatar Jan 25 '23 12:01 MaxNoetzold

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?

nightgrey avatar May 26 '23 18:05 nightgrey

Same here

hiramhuang avatar Jul 07 '23 23:07 hiramhuang