BitPhinix / slate-yjs

Yjs binding for Slate
https://docs.slate-yjs.dev
MIT License
514 stars 73 forks source link

`Cannot read properties of null (reading 'parent')` during `flushLocalChanges` #386

Open rcbevans opened 1 year ago

rcbevans commented 1 year ago

I'm using

    "@slate-yjs/core": "^0.3.1",
    "@slate-yjs/react": "^0.3.0",
    "slate": "^0.91.3",
    "slate-history": "^0.86.0",
    "slate-hyperscript": "^0.77.0",
    "slate-react": "^0.91.3",
    "y-protocols": "^1.0.5",
    "y-websocket": "^1.4.5",
    "yjs": "^13.5.47",

I am seeing infrequent errors (Cannot read properties of null (reading 'parent')) coming from yjs YText (yjs/src/types/YText.js) that I have been unable to reproduce, but are cropping up occasionally in production telemetry when users are collaborating on a document.

Call stack is

Crashed in non-app:
../../../node_modules/yjs/src/types/YText.js
in deleteText
<anonymous> in Array.forEach
Called from:
../../../node_modules/@slate-yjs/core/src/plugins/withYjs.ts
in f
<anonymous> in Array.forEach
Called from:
../../../node_modules/@slate-yjs/core/src/plugins/withYjs.ts
in e.flushLocalChanges

The crashing line is

  const parent = /** @type {AbstractType<any>} */ (/** @type {Item} */ (currPos.left || currPos.right).parent)

I'm not sure this is a slate-yjs specific (or even necessarily related) issue given the erroring code is in yjs:::YText, I will post an issue there too.