Regression: layout load functions no longer reflect mutations from their children
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
Before #14298, this pattern worked:
// +layout.server.ts
export const load = async ({ locals, url }) => {
url.pathname; // re-run this load function when the page changes
locals.data = [];
return {
data,
};
};
// +page.server.ts
export const load = async ({ locals }) => {
const data = await doSomeAsyncWork();
locals.data.push(data);
};
data would be populated with the contents of all child load functions. However, now that layout load functions are eagerly serialized, this capability is lost. I don't think this is the intention of #14298 because it talks about universal load functions, while this example is for server load functions.
Note that the child load function must be async to cause the bug.
Reproduction
Logs
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@sveltejs/adapter-auto: ^6.0.0 => 6.1.0
@sveltejs/kit: ^2.22.0 => 2.43.5
@sveltejs/vite-plugin-svelte: ^6.0.0 => 6.2.1
svelte: ^5.25.0 => 5.39.6
vite: ^7.0.4 => 7.1.7
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
Reproduce the issue using the linked StackBlitz and inspect src/routes/+page.server.js, along with the +layout.server.ts and +page.server.ts pattern described in the report. Compare behavior before and after #14298, focusing on an async child server load and eager layout serialization. Done means child mutations are reflected by the parent layout load again, with regression coverage for the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100