Skip to content

LayoutData is reset even when unchanged #6286

@CaptainCodeman

Description

@CaptainCodeman

Describe the bug

The /__data.json file is re-requested on every route change, even if the data is unchanged and not invalidate()'d. The data prop is then re-assigned which triggers updates within the app.

Response:

{"type":"data","nodes":[{"type":"skip"},null]}

It's less noticeable during dev, when things are local, but with a proper network request the latency can be noticeable - simulating a longer network request makes it apparent and it is also triggering a change on the Layout / Page data which is triggering store re-calcs and (I presume) potential re-renders.

Reproduction

Attach an extra hook to highlight the latency issue:

import type { Handle } from '@sveltejs/kit'

export const handle: Handle = async ({ event, resolve }) => {
  await delay(500)

  return resolve(event)
}

async function delay(ms: number) {
  await new Promise(resolve => setTimeout(resolve, ms))
}

Or, use that dev-tool network throttling option that I just remembered about while typing this ... 😊

Logs

No response

System Info

System:
    OS: macOS 12.5.1
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 1.89 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.0 - /usr/local/bin/node
    npm: 8.3.1 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 102.1.39.111
    Chrome: 104.0.5112.101
    Chrome Canary: 107.0.5260.0
    Firefox: 103.0.2
    Safari: 15.6.1
    Safari Technology Preview: 16.0
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.66 
    @sveltejs/adapter-node: next => 1.0.0-next.87 
    @sveltejs/kit: next => 1.0.0-next.440 
    svelte: ^3.49.0 => 3.49.0 
    vite: ^3.0.9 => 3.0.9

Severity

serious, but I can work around it

Additional Information

Related to #6201 (couldn't add a comment to it)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions