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

Svelte 5 + <svelte:head> hydration error #11519

Closed
1 task
amit13k opened this issue Jul 21, 2024 · 1 comment
Closed
1 task

Svelte 5 + <svelte:head> hydration error #11519

amit13k opened this issue Jul 21, 2024 · 1 comment
Labels
needs triage Issue needs to be triaged pkg: svelte Related to Svelte (scope)

Comments

@amit13k
Copy link

amit13k commented Jul 21, 2024

Astro Info

Astro                    v4.12.2
Node                     v18.20.3
System                   Linux (x64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             @astrojs/svelte

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

After the Astro + Svelte 5 snippet issue was fixed recently (#11149), I tried using mode-watcher in an astro project. I am getting this hydration error, TypeError: Cannot read properties of null (reading 'nodeType'). It seems to be related to the use of <svelte:head>.

MRE using mode-watcher

MRE using svelte component with just <svelte:head>

Some discussion here, sveltejs/svelte#12409 (comment).

Is this a bug(svelte or astro?) or just a limitation when using svelte5 with astro ?

What's the expected result?

No hydration errors

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-auhvgj-unik9c?file=src%2Fpages%2Findex.astro,package.json,src%2Fpages%2F_a.svelte

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jul 21, 2024
@bluwy bluwy added the pkg: svelte Related to Svelte (scope) label Jul 22, 2024
@bluwy
Copy link
Member

bluwy commented Jul 22, 2024

I think this is a limitation with head rendering in Astro from UI frameworks currently. We can't append the head from the Svelte component because when streaming HTML, the head may (and likely already had) been streamed, so we can't backtrack and add the head.

IIRC I don't think there's hydration errors in Svelte 4 and perhaps Svelte 5 could do the same in a fail-safe way. The issue is that in Svelte 5's head hydration here, it did not account when nextSibling ends and becomes null due to the hydration marker not existing at all.

I'd suggest reporting to https://github.com/sveltejs/svelte to see if it's something they're willing to fix (or deem a bug), but otherwise I think it's something Astro couldn't support for the time being (in SSR).

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged pkg: svelte Related to Svelte (scope)
Projects
None yet
Development

No branches or pull requests

2 participants