I found the yjs have it's own protocol and communicate with binary data, now I want to print the text content of the message for debugging, I have read this issue https://discuss.yjs.dev/t/decoding-yjs-messages/264/4 and found the Y.logUpdateV2(data);
from here https://docs.yjs.dev/api/document-updates, so I log the plain text on the text like this:
wsProvider.on('message', (event: MessageEvent) => {
const data: Uint8Array = new Uint8Array(event.data);
Y.logUpdateV2(data);
});
but the code shows error:
decoding.js:103 Uncaught RangeError: Invalid typed array length: 17656330
at new Uint8Array (<anonymous>)
at readUint8Array (decoding.js:103:16)
at readVarUint8Array (decoding.js:118:45)
at new UpdateDecoderV2 (UpdateDecoder.js:175:72)
at Module.logUpdateV2 (updates.js:126:25)
at CollarEditorService.ts?t=1698578910264:98:7
at observable.js:154:90
at Array.forEach (<anonymous>)
at WebsocketProvider.emit (observable.js:154:77)
at websocket.onmessage (y-websocket.js:144:16)
is it possible to fixed this issue? what should I do to output the plain text of yjs? I also tried the Y.logUpdate(data);
, still could not work.