sveltejs / sveltejs/kit

Dev builds make `__data.json?x-sveltekit-invalidated=01` requests even if `+page.server*` does not export a load function

Open
#10,022 2 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

load / layout
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

I have some routes with forms where I define form actions in their +page.server files. None of these +page.server files have a load function.

I noticed a bit of lag (~300ms) when navigating to those pages in dev builds, which looks to be coming from __data.json?x-sveltekit-invalidated=01 requests which always return: {"type":"data","nodes":[{"type":"skip"},{"type":"skip"},{"type":"data","data":[null],"uses":{}}]}. It seems like I can workaround this by removing the individual +page.server files on each route and moving them to a special, dedicated route that wouldn't be loaded by users, but that feels less than ideal.

It looks like this issue was filed before and fixed:

Is it expected for this to still happen in dev builds? It's not a big deal since it's seemingly in dev builds only, but it led to some confusion since we thought we had accidentally introduced latency we didn't expect until we tested outside of dev.

I made a minimal reproduction in Stackblitz with an empty +page.server file and see the same issue.

Is there a recommended or conventional approach on the placement of such form actions (e.g. in a dedicated route which avoids this also in dev)? Thanks!

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-gegmdq?file=src%2Froutes%2Fpage3%2F%2Bpage.svelte.

Logs

No response

System Info
Stackblitz:

 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: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.1.0 
    @sveltejs/kit: ^1.5.0 => 1.18.0 
    svelte: ^3.54.0 => 3.59.1 
    vite: ^4.3.0 => 4.3.8
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 with the linked StackBlitz reproduction and inspect src/routes/page3/+page.svelte alongside the route's +page.server file. Run it in a dev build, observe the __data.json?x-sveltekit-invalidated=01 request, and trace why it occurs when the server file has form actions but no load function. Done means the unnecessary request is avoided without breaking form actions.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.