Skip to content

+page.svelte should not load data from parent +page.server.ts #15397

Open

Description

@BaldoTuttle

Describe the bug

Lets say I have the following project structure:
Image
If I navigate from the shop page to the product page and then back to the shop page, the product page gets the data from the shop load function before navigation to the shop page.

The product page should not get the load data from the shop page.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-stp9cyxx?file=src%2Froutes%2Fshop%2F%2Bpage.server.ts

Logs

Navigating to shop page: shop {load: 'shop'}

Navigating to product page: shop {load: '[product]'}
product {load: '[product]'}

Navigating back to the shop page: product {load: 'shop'}
shop {load: 'shop'}

System Info

System:
    OS: macOS 26.3
    CPU: (12) arm64 Apple M2 Max
    Memory: 380.69 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.11.0 - /Users/frankherzog/.nvm/versions/node/v24.11.0/bin/node
    npm: 11.10.0 - /Users/frankherzog/.nvm/versions/node/v24.11.0/bin/npm
  Browsers:
    Chrome: 145.0.7632.76
    Firefox: 146.0.1
    Firefox Developer Edition: 145.0
    Safari: 26.3
  npmPackages:
    @sveltejs/adapter-node: ^5.5.2 => 5.5.3 
    @sveltejs/kit: ^2.50.2 => 2.53.0 
    @sveltejs/vite-plugin-svelte: ^6.2.4 => 6.2.4 
    svelte: ^5.51.0 => 5.53.3 
    vite: ^7.3.1 => 7.3.1

Severity

serious, but I can work around it

Additional Information

No response

Activity

  1. Nic-Polumeyv commented on Jul 17, 2026

    @Nic-Polumeyv
    Member

    I rebuilt this repro's structure and drove the shop → product → shop cycle while watching the console. I can reproduce the reported log output, but only when the pages observe data with $inspect. With $inspect('product', data) in each page I get exactly the reported pattern on kit 2.53.0 + svelte 5.53.3, kit 2.70.0 + svelte 5.56.5, and kit 3.0.0-next:

    to product:
      shop {load: [product]}      <- outgoing page
      product {load: [product]}
    back to shop:
      product {load: shop}        <- outgoing page
      shop {load: shop}
    

    $effect, $effect.pre, effect cleanup at destroy time, template reads of route-specific nested data, legacy $:, and page.data from $app/state never see the other route's data on the same versions, in either direction.

    During navigation the new data is written while the old component is still mounted, and the data swap plus component swap commit in a single flush. Ordinary reactivity never observes the intermediate state. $inspect does because inspect effects intentionally run synchronously at mutation time, which is what lets $inspect(...).with(console.trace) point at the code that caused a change.

    The variants of this that could break real code were fixed separately. Blur handlers running after the data update (#14575, #13276) were fixed by #15452 in kit 2.66.0, and #12851's template TypeError no longer reproduces on current Svelte.

    So unless you were seeing this with something other than $inspect, I don't think there's a kit bug left here. Making $inspect skip components that are about to be destroyed would be a sveltejs/svelte question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions