Slate: 0.47.x - seems nearly impossible to debug certain issues

Created on 10 Jun 2019  路  8Comments  路  Source: ianstormtaylor/slate

Technically the issue I'm seeing appears to be in slate-react, not slate

I'm upgrading from Slate 0.45.x, and overall it's been simple, but trying to fix my custom decorator functions is proving quite difficult. If anything goes wrong in the decoration or annotation part of the editor, all I get is: TypeError: Cannot read property 'ownerDocument' of null

You get this same error if you don't pass {...attributes} to a custom node, but I can't figure out for the life of me what in my decorator functions I'm trying to upgrade is throwing this error...

It's been about 4 hours of blackbox debugging, and though I've made progress, I'm still facing the exact same error. It's just been slicing through errors all day to find the same error cropping up. I've inspected my decoration function in excruciating detail and I can't find any issue, and the error message gives no clues.

Am I overlooking something simple? Is there a way we can get more explicit error messages, if this isn't just me being dumb?

Full message:

   TypeError: Cannot read property 'ownerDocument' of null
   at getDocument (webpack://renderer/./node_modules/get-document/index.js?:37:30)
    at getWindow (webpack://renderer/./node_modules/get-window/index.js?:43:13)
    at Content.componentWillUnmount (webpack://renderer/./node_modules/slate-react/lib/slate-react.es.js?:1660:69)
    at callComponentWillUnmountWithTimer (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:17169:12)
    at HTMLUnknownElement.callCallback (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:149:14)
    at Object.invokeGuardedCallbackDev (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:199:16)
    at invokeGuardedCallback (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:256:31)
    at safelyCallComponentWillUnmount (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:17176:5)
    at commitUnmount (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:17553:11)
    at commitNestedUnmounts (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:17584:5)
    at unmountHostComponents (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:17845:7)
    at commitDeletion (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:17904:5)
    at commitAllHostEffects (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:18685:11)
    at HTMLUnknownElement.callCallback (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:149:14)
    at Object.invokeGuardedCallbackDev (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:199:16)
    at invokeGuardedCallback (webpack://renderer/./node_modules/react-dom/cjs/react-dom.development.js?:256:31)

All 8 comments

Yes I do get annoyed at time with the debug-ability. Sometimes you will get a massive stack of internal slate calls, with your internal call at the bottom. And the actual error message can be very cryptic. Perhaps there needs to be more checks in the API (e.g. checking that arguments are as expected) so that you can get a finer idea of what went wrong.

I was also banging my head about this error. Dug into the package and found it meant that a node is undefined, which led me to my renderBlock function...I wasn't returning next() as a default meaning that in some cases there was nothing being returned from the function - hence the undefined node. Could be that other things cause this ownerDocument error too

I get this same issue

@danmckeon thanks for your response, I somehow overlooked it. Unfortunately that's not the case. I learned my lessons about the dangers of forgetting next() back around [email protected].

My renderBlock has default: return next(); and I'm still seeing this error when attempting to load the editor. Any ideas?

@josh-g3 make sure you're passing all the props.attributes to all your other blocks. I think that's the prop name. I had to abandon Slate 0.47 for now though so I can't easily reference my code, sorry.

I didn't have problems besides with decorations, which forced me to give up and revert my changes after 6 straight days.

Got hit with this error when attempting annotations. on Slate 0.47

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ianstormtaylor picture ianstormtaylor  路  3Comments

JSH3R0 picture JSH3R0  路  3Comments

YurkaninRyan picture YurkaninRyan  路  3Comments

bengotow picture bengotow  路  3Comments

varoot picture varoot  路  3Comments