Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Solid Query] Hydration Mismatch error #2132

Open
PeterDraex opened this issue Apr 16, 2024 · 7 comments
Open

[Solid Query] Hydration Mismatch error #2132

PeterDraex opened this issue Apr 16, 2024 · 7 comments
Labels
unverified bug Bug yet to be verified

Comments

@PeterDraex
Copy link

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

  1. Open console
  2. 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

@elite174
Copy link
Contributor

@PeterDraex
Copy link
Author

PeterDraex commented Apr 18, 2024

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.

@indeyets
Copy link

it works a bit different with solid-query 5.29:

  1. seems to reach success-state
  2. but still shows Hydration Mismatch in console

@indeyets
Copy link

attn @ardeora

@ryansolid
Copy link
Member

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.

@ardeora
Copy link

ardeora commented Apr 26, 2024

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.

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

@ryansolid
Copy link
Member

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.

@ryansolid ryansolid changed the title Hydration Mismatch error [Solid Query] Hydration Mismatch error Jun 27, 2024
@ryansolid ryansolid added the unverified bug Bug yet to be verified label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified bug Bug yet to be verified
Projects
None yet
Development

No branches or pull requests

5 participants