Encountering random TypeErrors

I see the following (and similar) exceptions happen in my app w/ CodeMirror 6. I am using v0.18.1. This happens for users using Google Chrome Mobile (mostly v64 and v87, Android). Since I get notified about this through an error tracking service on production, I may have limited amount of information on this error.

The following is the stack trace:

TypeError: Cannot read property 'nextSibling' of null
    at parentNode (webpack://toph/node_modules/@codemirror/view/dist/index.js:426:8)
    at insertBefore (webpack://toph/node_modules/@codemirror/view/dist/index.js:435:15)
    at  (webpack://toph/node_modules/@codemirror/view/dist/index.js:292:12)
    at lastChild (webpack://toph/node_modules/@codemirror/view/dist/index.js:1124:28)
    at  (webpack://toph/node_modules/@codemirror/view/dist/index.js:306:4)
    at track (webpack://toph/node_modules/@codemirror/view/dist/index.js:1718:16)
    at this (webpack://toph/node_modules/@codemirror/view/dist/index.js:4552:12)
    at style (webpack://toph/node_modules/@codemirror/view/dist/index.js:1709:21)
    at startState (webpack://toph/node_modules/@codemirror/view/dist/index.js:1696:57)
    at facet (webpack://toph/node_modules/@codemirror/view/dist/index.js:5001:27)
    at dispatch (webpack://toph/node_modules/@codemirror/view/dist/index.js:4928:13)
    at  (webpack://toph/node_modules/@codemirror/view/dist/index.js:4970:50)
    at annotations (webpack://toph/node_modules/@codemirror/view/dist/index.js:2807:16)
    at event (webpack://toph/node_modules/@codemirror/view/dist/index.js:2783:12)
    at  (webpack://toph/node_modules/@codemirror/view/dist/index.js:2750:4)
    at style (webpack://toph/node_modules/@codemirror/view/dist/index.js:2945:57)
    at registeredEvents (webpack://toph/node_modules/@codemirror/view/dist/index.js:2653:17)

Here are some tidbits about user interactions that lead to this exception:

Not sure what else can I provide to help debug this further, but please do let me know.

I will of course try to reproduce it on my end and share any other information I get from it.

I’m a bit confused how there are two native DOM functions/properties at the top of the stack trace (parentNode and insertBefore), both with source reference in the @codemirror/view package. But the nextSibling error suggests this is happening in the rm function.

However, that can only be called with null if there’s something rather broken about the content view tree, which is a problem that would have started elsewhere, and thus is hard to debug from the stack trace. It would be really helpful if you can find a way to reproduce this.