Invalid update from client

Hello, I have developed a distributed Slate editor application based on a server and several clients, connected through websockets, sharing the same document. The code is based on the example provided in the demos, so nothing fancy here. The problem is that I started seeing in the server logs errors of the type:

Caught error while handling a Yjs update SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at UpdateDecoderV1.readJSON (/var/task/node_modules/yjs/src/utils/UpdateDecoder.js:114:17)
at Array.readContentFormat (/var/task/node_modules/yjs/src/structs/ContentFormat.js:103:90)
at readItemContent (/var/task/node_modules/yjs/src/structs/Item.js:699:83)
at readClientsStructRefs (/var/task/node_modules/yjs/src/utils/encoding.js:164:13)
at /var/task/node_modules/yjs/src/utils/encoding.js:391:16
at transact (/var/task/node_modules/yjs/src/utils/Transaction.js:399:5)
at readUpdateV2 (/var/task/node_modules/yjs/src/utils/encoding.js:384:3)
at applyUpdateV2 (/var/task/node_modules/yjs/src/utils/encoding.js:479:3)
at Object.applyUpdate (/var/task/node_modules/yjs/src/utils/encoding.js:493:65)

It sounds to me that the client is sending an update containing an ‘undefined’ structure. What could be the cause of such behavior?
Every time the client connects with the server it sends a syncStep1 message, the server replies with a syncStep2 then a syncStep1, the issue looks to happen when the client sends a response to the latter message. What am I doing wrong here?


You should probably post this as a bug report (including the encoded Yjs document) to the editor-binding project you are using.

Jus a guess: the editor-binding seems to set formatting attributes that are not JSON objects: E.g. { bold: undefined } is not valid JSON because undefined is not JSON-encodable.