Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes the page store subscription to sometimes return an empty object in development mode with sveltekit in devmode wit vite?

Tags:

vite

sveltekit

subscribing to page store sometimes results in an empty object

debugging in chrome devtools shows an empty object

This does not occur every time and only in development mode with vite as a dev server.

I tried to subscribe after the component is mounted as you see in the image, but that does not make difference. Sometimes clearing the browser cache resolves the issue but not always. I am really lost here because this is difficult to debug. It looks like some kind of race condition that the page object is not loaded yet. I access the development server through a cloud-flare tunnel with https. Any help would be greatly appreciated.

like image 286
Ronald Brinkerink Avatar asked Jan 17 '26 18:01

Ronald Brinkerink


1 Answers

I was getting an empty page object, but I was also doing something unusual. I needed to test a payment provider, but they will only work on the domain of my business. So I had set a dns record on my domain from testing.<mydomain>.com to my home ip and had forwarded ports in my router to my sveltekit dev server. I was also using cloudflare and it turned out that setting cloudflare into dev mode (disabling caching) fixed the issue. From debugging it looked like cached pages from my production site interfered with hydration on my dev site causing sveltekit to not load properly.

So look into and possibly clear/disable whatever caching you have is a suggestion.

like image 173
Sámal Rasmussen Avatar answered Jan 19 '26 13:01

Sámal Rasmussen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!