svelte: Cannot read properties of undefined (reading 'call')
Describe the bug
It works in browser and Astro’s npm run dev .
I’m getting this error when trying to test with Vitest of Astro page with svelte file.
TypeError: Cannot read properties of undefined (reading 'call')
// edited - moved to Logs section
Reproduction
If required then later might try to repro. Its big page with runes, functions passed as props and template.
EDIT:
https://stackblitz.com/edit/github-ch9tapzs?file=test%2Fhappy-dom-env.test.ts&on=stackblitz
After dependencies install, stop npm in terminal and run npm run test
Logs
TypeError: Cannot read properties of undefined (reading 'call')
❯ get_first_child node_modules/svelte/src/internal/client/dom/operations.js:81:28
80| /**
81| * @template {Node} N
82| * @param {N} node
| ^
83| * @returns {Node | null}
84| */
❯ eval node_modules/svelte/src/internal/client/dom/template.js:48:91
❯ eval node_modules/svelte/src/internal/client/dev/elements.js:13:15
❯ Test src/components/test.svelte:15:12
❯ render node_modules/svelte/src/internal/server/index.js:121:2
❯ Object.renderToStaticMarkup node_modules/@astrojs/svelte/server.js:45:49
❯ renderFrameworkComponent node_modules/astro/dist/runtime/server/render/component.js:189:68
❯ renderComponent node_modules/astro/dist/runtime/server/render/component.js:368:10
System Info
System:
OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
CPU: (2) x64 Intel(R) Core(TM)2 Duo CPU E4500 @ 2.20GHz
Memory: 464.32 MB / 3.82 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
pnpm: 9.15.2 - ~/.local/share/pnpm/pnpm
bun: 1.1.6 - ~/.bun/bin/bun
Watchman: 20201115.021953.0 - /usr/local/bin/watchman
Browsers:
Chrome: 132.0.6834.83
npmPackages:
svelte: ^5.1.3 => 5.16.2
Severity
blocking all usage of svelte
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (4 by maintainers)
I also have this problem from time to time. For me it helps to delete my node_modules and .svelte-kit folder and reinstall all dependencies. It happens sporadically during development. I also use tailwind and daisyui. But I’m sure it happened with the old versions too.
I find my problem is something cache related because I can access the localhost:5173 without this error. This reminded me that I used cloudflare tunnels to host a local dev server on a domain. I guess that’s the reason why not so many people ran into this problem.
Some steps to solve this:
follow this issue to disable cache for tunnels: https://github.com/cloudflare/cloudflared/issues/186
restart tunnel service
sudo systemctl restart cloudflaredchange something & build the project, clean the browser cache to reload the page
hopefully the error will be gone.
@Gbps Thanks for writing. Astro doesn’t use SvelteKit, just Svelte alone but maybe there’s culprit in
axios-retry