[Solid Query] Hydration Mismatch error
Describe the bug
Getting an error:
Error: Hydration Mismatch. Unable to find DOM nodes for hydration key: s00-0-0-0-0-0-0-0-0-1-3
Your Example Website or App
https://stackblitz.com/edit/github-pqy8j7-jhayd9?file=src%2Fcomponents%2FPage.tsx
Steps to Reproduce the Bug or Issue
- Open console
- See Hydration Mismatch Error
Expected behavior
Blank page is displayed, with no errors in console.
Screenshots or Videos
No response
Platform
Windows, Chrome 123
Additional context
No response
This was solved here: https://discord.com/channels/722131463138705510/1229910798135066716/1230151418569298052
This was solved here: https://discord.com/channels/722131463138705510/1229910798135066716/1230151418569298052
Yeah, a workaround of deferStream: true was suggested on Discord (thank you). Another available workaround is using <Show> instead of <Switch>.
The issue seems to be that as soon as Switch matches a case it renders and flushes the data. So in this case when pending case is matched it renders that and then yields.
it works a bit different with solid-query 5.29:
- seems to reach success-state
- but still shows Hydration Mismatch in console
attn @ardeora
It's pretty hard for me to debug Solid Query stuff. Like I need to put time aside to get into the code base. It might be easiest to report bugs against them and then they make reproductions with pure createResource so I can better see what is going on without tracing through that code.
It's pretty hard for me to debug Solid Query stuff. Like I need to put time aside to get into the code base. It might be easiest to report bugs against them and then they make reproductions with pure
createResourceso I can better see what is going on without tracing through that code.
Apologies @ryansolid Here is an example with just using createResource.
https://stackblitz.com/edit/github-pqy8j7-n87wnf?file=src%2Fcomponents%2FPage.tsx
I think the Switch component (during SSR) eagerly evaluates and flushes the data when any case matches? In this case you would always see the pending string in the HTML after hydration
Sorry took me a while to look at this. But in the createResource scenario it is acting how I'd expect. The problem is that checking loading doesn't suspend.. the server doesn't wait. And in the client it is available and we get the mismatch unless the timing works out just right. You need to read the data to suspend.
If I remove the first condition or change the first switch condition to the following it works.
<Match when={!data() && data.loading}>pending</Match>
The reason reading loading doesn't suspend is it is the mechanism we use to purposefully opt into tearing. But tearing during hydration won't work.
However making that fix in the Solid Query example I think still doesn't work. It doesn't error during hydration but it also doesn't show anything. So we will need to narrow this down further.