Spurious/outdated warning with async SSR
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
SvelteKit has the following warning (source):
Avoid calling
fetcheagerly during server-side rendering — put yourfetchcalls insideonMountor aloadfunction instead
While I'm not certain about the original context this warning was added under, I'm assuming it was because the fetch result would simply be lost during SSR, resulting in a wasted call.
With async SSR I don't believe this warning should be emitted as long as the fetch called is awaited.
If I've misunderstand then perhaps some additional clarification on the purpose of the warning is needed.
Reproduction
- Enable async svelte
- Call
await fetch(...) - Observe the warning during SSR
Logs
System Info
System:
OS: Linux 6.15 Arch Linux
CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
Memory: 6.93 GB / 15.54 GB
Container: Yes
Shell: 5.3.3 - /bin/bash
Binaries:
Node: 22.17.0 - /home/yung/.nvm/versions/node/v22.17.0/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 10.9.2 - /home/yung/.nvm/versions/node/v22.17.0/bin/npm
pnpm: 10.13.1 - /home/yung/.local/share/pnpm/pnpm
Browsers:
Chromium: 139.0.7258.66
Firefox: 141.0
Firefox Developer Edition: 141.0
npmPackages:
@sveltejs/adapter-auto: ^6.0.0 => 6.1.0
@sveltejs/kit: ^2.43.8 => 2.43.8
@sveltejs/package: ^2.0.0 => 2.5.1
@sveltejs/vite-plugin-svelte: ^6.0.0 => 6.2.0
svelte: ^5.39.9 => 5.39.9
vite: ^7.0.4 => 7.1.5
Severity
annoyance
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 in packages/kit/src/runtime/server/page/render.js around line 195, where the warning is emitted. Reproduce the issue with async Svelte SSR and an awaited fetch, then trace the warning condition and verify that the resulting behavior matches the intended SSR handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100