sveltejs / sveltejs/kit

Spurious/outdated warning with async SSR

Open
#14,613 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

svelte 5
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 fetch eagerly during server-side rendering — put your fetch calls inside onMount or a load function 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
  1. Enable async svelte
  2. Call await fetch(...)
  3. 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.