-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
I noticed something yesterday after upgrading on of my SvelteKit projects from 2.37.0 to 2.37.1.
I created a repo that reproduces the issue as described below, repo can be found here: https://github.com/ReindDooyeweerd/sveltekitbug
The issue:
In my +layout.server.ts i normally fetch some data that is used throughout the whole website like menu data etc, this works great.
In the repo posted above i created a [slug] with a +page.server.ts which also fetches some data so https://localhost:5173/ shows the data fetched in the layout and https://localhost:5173/a shows both the data from +layout.server.ts and +page.server.ts => https://share.cleanshot.com/FV2B0qQYx2nNRLFS7mfQ
So far so good. Then i created a [slug_2] inside [slug], added a fetch also BUT i make sure that doesn't return any data and throw a 404. So https://localhost:5173/a/b should end up on +error.svelte
if (!fetchedPageData || Object.keys(fetchedPageData).length === 0) {
error(404, 'Page not found');
}
This renders the +error.svelte but now the weird stuff happens since 2.37.1, the layout data becomes empty also: https://share.cleanshot.com/fx5VwqlRWJ67cLlKMKmz
While on version 2.37.0 with the exact same code i get this: https://share.cleanshot.com/x5bFFgz84gTjNJxVxjpR
Reproduction
- Clone https://github.com/ReindDooyeweerd/sveltekitbug
- npm install && npm run dev
- visit https://localhost:5173 => layout data in pre tags
- visit https://localhost:5173/a => layout data + page data in pre tags
- visit https://localhost:5173/a/b => fetch is empty, +error.svelte is rendered and both pre tags are empty
- change sveltekit version to 2.37.0 in package.json and start from 2 and on 5. you will see that the layout data is still available while pagedata is empty as expected
Version of the repo on stackblitz: https://stackblitz.com/~/github.com/ReindDooyeweerd/sveltekitbug
Logs
Nothing in the browser console or terminalSystem Info
System:
OS: macOS 15.6.1
CPU: (10) arm64 Apple M2 Pro
Memory: 641.34 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.17.0 - ~/.nvm/versions/node/v22.17.0/bin/node
npm: 10.9.2 - ~/.nvm/versions/node/v22.17.0/bin/npm
Browsers:
Chrome: 140.0.7339.80
Safari: 18.6
npmPackages:
@sveltejs/adapter-auto: ^6.1.0 => 6.1.0
@sveltejs/kit: ^2.37.0 => 2.37.1
@sveltejs/vite-plugin-svelte: ^6.1.4 => 6.1.4
svelte: ^5.38.7 => 5.38.7
vite: ^7.1.5 => 7.1.5Severity
blocking an upgrade