sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.67k stars 1.93k forks source link

Page store update bug with svelte 5 #11533

Closed PatrickG closed 9 months ago

PatrickG commented 9 months ago

Describe the bug

I'm not sure if this is a Svelte5 bug or a Svelte5 specific Sveltekit bug. But I was not able to reproduce it in the Svelte5 repl.

Reproduction

Svelte 5 (Same example with Svelte 4 is working)

Click the "Toggle" Button. The slotted content changes from +error.svelte to +page.svelte correctly, but the 3 lines above the button stay the same. In the console, you can see something like: update {something: true, somethingShouldBe: false} something is a derived state from $page.status === 401 || $page.url.pathname === '/test' while somethingShouldBe is the exact same condition but inlined in the $inspect rune.

Strange thing is, if you change throw401 to initially be true in routes/+page.server.js, it works correctly. Or when you change all $page.status === 401 || $page.url.pathname === '/test' conditions to $page.status === 401 in routes/+layout.svelte, it works correctly as well.

Logs

No response

System Info

Svelte5
Sveltekit 1.30.3 & Sveltekit 2.*

Severity

blocking an upgrade

Additional Information

No response

PatrickG commented 9 months ago

I was able to reproduce it with Svelte 5

kiosion commented 8 months ago

Is this still an issue for you? I'm experiencing something similar testing out Svelte 5 with a SvelteKit project. When Subscribing to the built-in Page, Error, or Navigating stores, I get their initial state in the subscribe callback, but never any subsequent updates - e.g., using the auto-subscription syntax to get the current $page.url.pathname just returns the pathname from the initially-loaded route and never updates.