kit icon indicating copy to clipboard operation
kit copied to clipboard

await in <svelte:head> create troubles

Open enda opened this issue 3 years ago • 1 comments

Describe the bug

When using an {#await} in svelte:head, the head elements starts to be broken.

-- On a more major project, some meta are duplicated without needing to change route, and when I change route, meta are just append and the older not cleaned.

I use #await in head because I stream datas from +page.ts. I stream datas only if browser === true, to make the route reactivity more faster and display Content Loader before the data are present, but datas are being awaited in +page.ts to be also rendered by SSR. I'm not sure if it's the best way, but it's the one I found while we dont have a +page.loading.svelte :)

Reproduction

Fork sveltekit

npm create svelte@latest my-app
cd my-app
npm install
npm run dev -- --open

Add this code just before </svelte:head>

  {#await true then}
    <link rel="hello" as="world" />
  {/await}

Open browser and console, change route and come back to home, you have two <link rel="hello" as="world />

Screenshot 2023-10-17 at 19 50 03

Logs

There is no log in browser console or from server

System Info

System:
    OS: macOS 13.5.2
    CPU: (8) x64 Intel(R) Core(TM) i7-8557U CPU @ 1.70GHz
    Memory: 174.19 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
  Browsers:
    Chrome: 118.0.5993.70
    Safari: 16.6
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.1.0 
    @sveltejs/adapter-node: ^1.3.1 => 1.3.1 
    @sveltejs/kit: ^1.20.4 => 1.25.2 
    svelte: ^4.0.5 => 4.2.1 
    vite: ^4.4.2 => 4.4.11

Severity

blocking an upgrade

Additional Information

No response

enda avatar Oct 17 '23 18:10 enda

It seems to be more a sveltejs issue than a sveltekit issue. Severity is moving from blocking an upgrade to annoyance since I found a work around (see new issue below). I reopen this issue here: https://github.com/sveltejs/svelte/issues/9329

I'm closing this one

enda avatar Oct 18 '23 16:10 enda