gridsome: Failed to execute 'appendChild' on 'Node'
Description
I’m getting a really weird issue, that only appears to be happening on Chrome on Android (v72.0.3626, can’t confirm other versions).
Steps to reproduce
On a Android device (ideally hooked up via ADB + Chrome inspector):
- go to https://2019.steveedson.co.uk
- click on one of my articles
- notice no console errors
- refresh the page
- Get the error:
Failed to execute 'appendChild' on 'Node': This node type does not support this method.
It will then break the rest of the JS execution, the router links and other Vue bindings no longer work. This is fine on desktop though.
"Error: Failed to execute 'appendChild' on 'Node': This node type does not support this method.
at Object.appendChild (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5161:8)
at insert (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5472:17)
at createElm (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5390:9)
at createChildren (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5481:9)
at hydrate (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5809:11)
at hydrate (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5824:34)
at hydrate (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5824:34)
at hydrate (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5824:34)
at hydrate (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5824:34)
at VueComponent.patch [as __patch__] (webpack:///./node_modules/vue/dist/vue.runtime.esm.js?:5900:17)"
Expected result
No errors on mobile.
Environment
Libs:
- gridsome version: 0.5.4
- @gridsome/cli version: 0.0.7
Browser:
- [ ] Chrome (desktop) version XX
- [x] Chrome (Android) version v72.0.3626
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: v8.12.0
- Platform: Mac / Linux
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 48 (18 by maintainers)
Commits related to this issue
- fix: remove immediate tag due to https://github.com/gridsome/gridsome/issues/249 — committed to mseele/sve-tools by mseele 3 years ago
I think I’ve just figured this out actually, the only thing I could think of was a share button that is only enabled if the browser supports the
navigator.shareAPI. I check for this in mymain.jsfile:and then use it in my templates like so:
I’ve just changed the
v-iftov-show, and it’s solved the issue. My only guess is that because thev-ifremoves the element during SSR, it can’t be hydrated during the client side render, causing the issue? Would this make sense?For others that are having a similar issue, I was having the same error in sentry.io reports. It turned out to be that I had a computed property called
gpsAvailableand was doing av-if="gpsAvailable"in my template, I changed it tov-show="gpsAvailable"and that fixed it. apparently something to do with SSR re-hydration. Other googling lead me to similar things all dealing with newer browser API’s like location or websharing etc or malformed HTML.@LorenAmelang The problem here is that the post content is wrapped in a paragraph. That will make the generated HTML invalid if it contains any block elements (
h1,uletc.). Changing it to<div v-html="$page.post.content" />should help.Same problem, same solution as @MFukazawa , had a
<p v-html="">changed it to a DIV tag and that was it. Hard to find though …Another instance where I’ve seen this error appear (just spent 2 hours debugging it 🤕) is if you have a
<noscript>tag anywhere in your site. After I removed them and replaced them withv-ifs and a variable to see if a component has been mounted or not the error went away.Hi @platform-kit!
Did you follow the debugging steps listed in this thread? The main cases of this error we’ve seen so far are:
<noscript>tag - a<noscript>tag anywhere in your project could cause thisv-htmldirective on a<p>tag instead of a<div>tag could cause this, for examplev-if- If you’re using thev-ifdirective instead ofv-show, this can sometimes cause this issue. If it’s possible to usev-show, give that a try.Am I missing anything here folks? If none of these solve your problem, could you post a link to your repository?
@cossssmin You could check out the
headingsfield for markdown nodes. It will generate a list of headings for you.Is there a way to make the error message more helpful for this? I’ve run into this at the wrong time, unfortunately
@hacknug Yup and that made no difference on the
g-imagetag I had.I did see those ideas and none of them fixed the issue. For now, wrapping my entire layout in client-only has done the trick.
I’ve been running into this on build when deploying to Netlify (not in local dev).
Here’s the error message in the latest Chrome, running Gridsome 0.7.13
I don’t have a clue as to how to debug this. Any pointers would be appreciated.
@badrihippo @weaversam8 @Tummerhore I don’t think Vue has support for
<noscript>tags. I had the same problem when making the<g-image>component. It renders a fallback image in a<noscript>tag and I had to insert the fallback image as an HTML string to make it work (see here). I haven’t tested, but<noscript v-html="..." />might work too.@badrihippo - so far this issue is okay for recognizing and preventing the behavior, but if you want to open a new issue specifically targeting Gridsome’s lack of
<noscript>support, that wouldn’t be a bad idea.I’ve tried replacing
v-ifwithv-showbut I’m still getting this error. I’m not using any new browser APIs, and it’s happening in Firefox as well but with a slightly different message:HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. Here’s a deployment: https://5da7f5945b97a30008b6c5be--macguire.netlify.com/Any ideas?
Edit: The issue was Netlify forms. Found the solution via #361 (not having a certain hidden input seems to be the problem — see here for the solution)