Skip to content

Post request via fetch gets overriden/replaced in load() #633

Description

@lukasIO

Describe the bug
Two parallel (?) fetch POST requests (one from $layout.svelte, and one from index.svelte) with different contents end up having the same response on the client side.

Logs
nothing interesting happening in the logs

To Reproduce
I set up a repro repository here https://github.com/neesh-studio/sk-fetch-override-repro which loads two festival objects from a graphQL api.
One Festival is called "First Festival", the other "Another Festival".

The SSR implementation seems to work as there is a short flash of the "Another Festival" title on page refresh. But it get's replaced on the client with "First Festival".
What i get to see:
grafik

Expected behavior
what I expect to see:
grafik

I expect the fetch api to work the same on server and client and the client not overriding another (POST) request. (A quick test shows the behaviour seems fine for GET requests)

The problem goes away if I uncomment line 21 in api.ts

  if (typeof window !== "undefined") fetchApi = fetch;

Information about your SvelteKit Installation:

  • The output of npx envinfo --system --npmPackages svelte,@sveltejs/kit --binaries --browsers
System:
    OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
    Memory: 10.16 GB / 12.35 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
    npm: 6.14.11 - ~/.nvm/versions/node/v14.15.5/bin/npm
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.58 
    svelte: ^3.29.0 => 3.35.0 
  • Your browser
    Chrome: Version 89.0.4389.90 (64-Bit)

  • Your adapter (e.g. Node, static, Vercel, Begin, etc...)
    dev server

Severity
Minor, there is a workaround (as described) but I wanted to post the issue early in case this is somehow connected to #591

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions