sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
79.71k stars 4.22k forks source link

TypeError: Cannot read properties of null (reading 'nodeType') (Astro + Svelte 5) #13088

Open AdrianButler opened 2 months ago

AdrianButler commented 2 months ago

Describe the bug

I am getting this error and my svelte component will not load at all. It works perfectly fine in dev environment but when I build or run preview it stops working and the error is thrown in the console.

Reproduction

https://gist.github.com/AdrianButler/4b04009c797bf37599c6763d09111a0b

This component is being used in a astro file with the client directive of load

This only happens in production build and the component works perfectly fine in dev environment

Logs

faq/:1 [astro-island] Error hydrating /_astro/FaqQuestion.B9nkJrIu.js TypeError: Cannot read properties of null (reading 'nodeType')
    at Ut (template.BZob6Wd_.js:1:8993)
    at G (FaqQuestion.B9nkJrIu.js:1:1234)
    at render.Eek01tEQ.js:1:1270
    at Sn (template.BZob6Wd_.js:1:5360)
    at U (template.BZob6Wd_.js:1:6097)
    at k (template.BZob6Wd_.js:1:2186)
    at bt (template.BZob6Wd_.js:1:2805)
    at render.Eek01tEQ.js:1:1212
    at Sn (template.BZob6Wd_.js:1:5360)
    at U (template.BZob6Wd_.js:1:6097)

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
    Memory: 17.34 GB / 31.77 GB
  Binaries:
    Node: 22.6.0 - ~\AppData\Roaming\JetBrains\WebStorm2024.2\node\versions\22.6.0\node.EXE
    npm: 10.8.2 - ~\AppData\Roaming\JetBrains\WebStorm2024.2\node\versions\22.6.0\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527

Severity

blocking all usage of svelte

dominikg commented 2 months ago

this reads similar to https://github.com/sveltejs/svelte/issues/12601

please try updating to vite-plugin-svelte@^4.0.0-next.6. (requires using an override in your package.json)

if it does not fix the issue, we require a repo link with a reproduction, to be able to investigate.