-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: SSR breaks rendering of Select component when HMR is enabled #12601
Comments
I'm not sure if it's directly related (still digging into this) but I encounter an exception Also this seems unrelated to HMR, but rather seems like a hydration only issue. |
Hm, I'm not seeing any exceptions or errors in my browser or node console when refreshing.
If I go into svelte.config.js and set |
Ah you're right, it is related to It seems related to the generation of the svelte class. From the server the class is called |
vite-plugin-svelte uses a custom cssHash function during dev to ensure that dom nodes don't get different style hashes every time you edit css in your .svelte file. This is what you see as s-413vZPMk7oiT ( its a hash of the file path) |
It seems stable and i can confirm commenting that code out doesn't fix the issue. What's strange is that the class names don't match any selectors in the injected CSS string. Update: it was this after all, I was seeing a cached |
@dominikg Is this line meant to be used here? It never reaches it with hmr enabled. |
I also get a console error in the terminal when refreshing on the Select page:
Not sure if it's connected to this issue though. |
the only reason that line isn't reached would be emitCss false (which we ruled out above) or hasCss false, which would mean ssr compile did not produce css. |
@dominikg Upgrading
and
|
@pheuter Are you using the latest Svelte too? |
I tried with both 199 and 200, no difference in terms of the errors above. Think I'm able to repro the new |
I've updated the repro here to showcase the new This is a weird one and I'm not sure how to best explain it other than to note that it happens when you SSR on the page and the <div class="flex items-center gap-2">
<LucideMapPin class="h-4 w-4" />
{#if $formData.role === 'editor'}
{$formData.name} (Editor)
{:else if $formData.role === 'admin'}
{$formData.name} (Admin)
{:else}
{$formData.name}
{/if}
</div> Note that this only starts to happen after the upgrade to vite-plugin-svelte |
@pheuter I assume this is with HMR enabled too? What happens when you disable HMR? |
@trueadm Correct, the SSR rendering works just fine with |
the error comes from
and it looks like the loop ran out of siblings before encountering an end marker. If it was while(node) instead of while(true) that would not happen, however i assume something else borked the end marker before and that loop rightfully expected it to exist? removing this line https://github.com/sveltejs/vite-plugin-svelte/blob/2670424fc7f66cef6797286bee4e0be1aa03b4a8/packages/vite-plugin-svelte/src/utils/esbuild.js#L78 in vite-plugin-svelte fixes it, so it seems like hmr code in prebundled dependencies is somehow required for their hydration? |
@dominikg This seems like an esbuild bug then? |
@pheuter Can you please try with the latest version of |
@trueadm the issue persists for me with vite-plugin-svelte 4.0.0-next.6, if that's the newest |
just to be sure can you try again with |
hm, after forcing re-op with The same error persists when using a third party library though, and the author referenced it as a svelte issue: That is recreatable even with vite-plugin-svelte-next6, but it might be a library issue, not related to svelte anymore: https://stackblitz.com/edit/github-lahshv?file=src%2Froutes%2F%2Bpage.svelte |
@trueadm The issues I was encountering appear to be resolved with |
the issue is now also fixed on the libraries side : huntabyte/shadcn-svelte@3497b07 I think the issue can be closed! :) |
looks like everything works, thanks for confirming |
Describe the bug
See the minimal repro I created.
Reproduction
https://github.com/pheuter/hmr-repro
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: