kit icon indicating copy to clipboard operation
kit copied to clipboard

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

Open torablien opened this issue 2 years ago • 2 comments

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:

  • https://github.com/sveltejs/kit/issues/7967
  • https://github.com/sveltejs/kit/pull/8636
  • https://github.com/sveltejs/kit/releases/tag/%40sveltejs/kit%401.3.1

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

torablien avatar May 24 '23 00:05 torablien

I have the same issue when build using adapter-static and deploying on a Firebase Hosting.

image

hectordufau avatar Jun 21 '23 18:06 hectordufau