[Async] Nested layouts + client-side nav results in page store not being populated quickly
Nobody has claimed this yet.
- 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
- Clone this reproduction app
- Run
npm install && npm run dev - Go to
http://localhost:5173 - Click "Go to nested page (where the bug occurs)" link
- 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):
- Change
svelte.config.js: setasync: false - Restart dev server
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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