Skip to content

Spurious/outdated warning with async SSR #14613

@dangodai

Description

@dangodai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions