How to debug "Uncaught Transform Error"

I’m still in the process of finding my way through prosemirror and am just beginning to define my own schema. Currently I derive off the base schema. I don’t think I’ve really changed anything significant yet but I ran into a problem.

I set up my editor as shown in the basic demo and initialize it with JSON I generate in my backend. So far everything works. However when I try to change the type of a headline nothing happens and the console shows an “Uncaught Transform Error”. The same happens when I try to change some plain text into a headline.

My guess is that I did something wrong with either my schema or with setting up the editor, but I can’t figure out what. The problem remains if I remove any changes I did on the header node in my schema.

So my real question here is how do I approach such errors in Prosemirror? What would be good steps to debug this?

I tried to debug this further and figured out that the actual error was hidden.

The error is thrown In transform.js:

if (result.failed) { throw new TransformError(result.failed) }

result.failed is the actual error message (in my case “Invalid content for node doc”) but this message is never shown in Chrome’s JavaScript console - somehow the TransformError class must hide it. I guess that’s a bug? If you confirm, I can open a bug report for that.

Now I have to figure out why the doc node thinks it doesn’t allow headers…

It seems inheriting from Error is still very broken on current browsers – the message passed to the constructor appears to be simply dropped if you don’t explicitly override the constructor to pass it to super (which makes no sense, since that should be exactly what the default constructor does). This patch should help with that.

Thanks for the quick patch.

Regarding my error, it seems it is completely unrelated to my schema or the headline I’m trying to change, but is caused by some other node that was generated by my backend code and seems to violate something in my schema. At least it starts working again as soon as I delete the majority of my other content.

It seems like changing a headline is triggering a reevaluation of the whole document?

Of the sibling nodes of the node that was changed, yes, to ensure that the parent node’s content matches the schema’s specification of what content is allowed.