sveltejs / sveltejs/kit

[Async] Nested layouts + client-side nav results in page store not being populated quickly

Open
#14,798 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

load / layout svelte 5
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

When compilerOptions.experimental.async: true is enabled, reactive function calls in templates receive stale/incomplete $page.data during client-side navigation, while reactive statements see complete data in the same render cycle.

Expected vs Actual

Expected (async: false or page reload):

  • Item count: 3 (correct)
  • Reactive function calls see complete data

Actual (async: true + client-side nav):

  • Item count: 0 (incorrect)
  • Same data exists in reactive statements and template conditionals
  • Only function calls within template get stale data

Key Details

  • Server-side render (page reload): Works correctly
  • Client-side navigation: Bug appears
  • Bug pattern: Reactive inconsistency within single render cycle
  • Data structure: 4 nested layouts + page data via await parent()

The same $page.data store returns different values to different reactive contexts during client-side navigation when async mode is enabled.

Reproduction

https://github.com/PuruVJ/repro-async-bug-nested-layouts

  1. Clone this reproduction app
  2. Run npm install && npm run dev
  3. Go to http://localhost:5173
  4. Click "Go to nested page (where the bug occurs)" link
  5. Observe the "Item count" value

Expected vs Actual Behavior

With async: true (current config):

Client-side navigation (clicking link):

  • Item count: 0 ❌ (incorrect)
  • Has apiData: true
  • Full data shows 3 items in array

Page reload (F5 or direct URL):

  • Item count: 3 ✅ (correct)
  • Same complete data
With async: false (comparison):
  1. Change svelte.config.js: set async: false
  2. Restart dev server
  3. Test both navigation methods:

Client-side navigation (clicking link):

  • Item count: 3 ✅ (correct)

Page reload (F5 or direct URL):

  • Item count: 3 ✅ (correct)
Logs

System Info
System:
    OS: macOS 26.0.1
    CPU: (16) arm64 Apple M4 Max
    Memory: 5.25 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.1.0 - /opt/homebrew/bin/node
    npm: 11.3.0 - /opt/homebrew/bin/npm
    pnpm: 10.19.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 141.0.7390.109
    Safari: 26.0.1
  npmPackages:
    @sveltejs/adapter-auto: ^7.0.0 => 7.0.0 
    @sveltejs/kit: ^2.47.3 => 2.47.3 
    @sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1 
    svelte: ^5.41.2 => 5.41.2 
    vite: ^7.1.12 => 7.1.12
Severity

blocking an upgrade

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction app, install its dependencies, and run npm install && npm run dev. Compare client-side navigation with a page reload while async is enabled, then compare with async disabled; done means the item count and page data are consistent in both navigation paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.