question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

<g-link> doesn't actually change pages on build - Hydration issue

See original GitHub issue

Description

<g-link> updates the page title (in the browser tabs) and loads things like the console log but it does not change what I see on the page without reloading. In gridsome develop this is not an issue but gridsome build it fails.

I’m assuming I might have invalid HTML somewhere, but perhaps it could be something else, any suggestions?

I’ve looked at a lot of other similar g-link issues like https://github.com/gridsome/gridsome/issues/337 but to no prevail.

Steps to reproduce

https://github.com/element-softworks/atobtyres

Expected result

<g-link> should hydrate the pages without having to reload the page manually

Actual result

The page does visually not change unless I reload the page, I do think the code is loaded, just the view doesn’t seem to change.

Environment


Libs:
- gridsome version: 0.6.6
- @gridsome/cli version: 0.2.0


Browser:
- [x] Chrome (desktop) version
- [x] Chrome (iOS) version
- [x] Safari (desktop) version
 
For Tooling issues:
- Node version: 10.13  
- Platform: Mac

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:58 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
mschmidtkorthcommented, Jun 1, 2021

I’ve added another minimalistic repository to reproduce the failure with valid routes.

You can see that once you change the HTML from

<div>
	This is: INDEX
</div>

to

<div>
	This is: <strong>INDEX</strong>
</div

the page loads successfully again. It looks like gridsome is trying to access child nodes of the page which do not exist (my assumption is based on the fact that I saw Uncaught (in promise) DOMException: Failed to execute 'appendChild' on 'Node': This node type does not support this method on my production site).

For both sample repos no error message is shown and they work flawlessly in develop mode.


Generally I’ve seen (and read about) hydration issues pop up around:

  • A component producing HTML and wrapping the component in a tag which is not allowed (e.g. <p><Component /></p> or <p><Component><p><template name="test"></p></Component></p> where the component wraps its slot around <p> already (nested paragraphs are not allowed))
    • Using v-html to dynamically parse HTML: <p v-html="var" /> where var = <p>Text</p> (nested paragraphs are not allowed)
  • Nested <g-link>
  • Using data-netlify="true" in forms
  • Using beforeMount
  • Using dynamically generated content
  • Using <g-link> as root component of a page
  • Using <g-link> without a trailing slash
  • Using HTML entities such as <div>&nbsp;</div> instead of <div class="..."></div>
  • Having a comment that contains a component’s markup - e.g. <!-- <Social /> --> as this will show up as <!----> and cause a appendChild() exception
  • <transition> tags generate <span> which may not have <div> as children - use <transition tag='div'>
  • Disable HTML minification e.g. in netlify settings
  • Make sure all routes via <g-link> lead to valid paths
  • ? Having no data() method or one returning nothing instead of return {}
  • ? Invalid code like having an object returning something instead of a method (e.g. metaInfo: {return{}} instead of metaInfo() {return{}})
4reactions
AustinGilcommented, Mar 6, 2020

Two options I think could be acceptable would be that it breaks during development in the same way it breaks during production build. Or it at least gives a console warning if there’s invalid HTML. I mean, ideally a developer knows how to avoid invalid HTML, but machines are way better than humans at that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging and fixing hydration issues - somewhat abstract
Spotting hydration errors and fixing them can prevent serious user-facing performance issues, and since we do not get a signal during production ...
Read more >
What to do when home seller lies on seller disclosure forms
This issue was never mentioned by our seller in the seller disclosure statement. We did ask the seller about water leaks in the...
Read more >
Why does NextJS give this hydration error on dev server build ...
If you use create-next-app and paste this code, ... pages/index.js ... This hydration error in my example doesn't appear to be an issue...
Read more >
Municipal Annexation Handbook - Ancel Glink
Increasingly, residential and even commercial landowners may have been unwilling to annex to a nearby municipality are re-thinking those issues. In this era...
Read more >
Buyer's Responsibility To Change Utilities After Closing
The heat, electricity and water were on as well. Sellers Turned Off Utilities After Closing Without Informing Buyers. When we closed on the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found