JavaScript Exception: Cannot read property childNodes of undefined, with extension Dark Reader

The problem here is that Elm claims the whole <body>, in all other VDOM systems I’m aware of it is best practice that the library just inserts its own nodes into the root and manages only these - which of course has still problems when some other party messes with your nodes - see e.g. this issue on create-react-app. As suspected these kind of errors will show up for react as well - we get these at work from time to time but mostly from anti-virus software browser plugins messing with the DOM in some way. I guess you could find a hacky way to match the error message in a global catch-all handler but some browsers - which could it be? - dutifully localize the error messages so that doesn’t seem like a viable option. I’d wager using your stats and building a whitelist of plugins that are known to cause problems could be feasible but you’ll obviously never catch all of them ahead of time if you even can detect their presence in the first place.

I guess the Elm VDOM could be a bit more clever about these situations and try to repair the DOM - or make educated guesses for obvious situations like an additional <script> - as reflecting the DOM state back to the app is clearly not an option. I think Browser.application overtaking the DOM is not a good idea in real world situations, so maybe this could be worth an issue on elm/browser?

1 Like