Skip to content

Internal Error: immutable for sveltekit fetch #13857

@JLewinski

Description

@JLewinski

Describe the bug

Using the sveltekit fetch in a +page.server.ts load function will cause an Internal Error whenever a cookie is set in the hooks.server.ts handle function.

Reproduction

  1. Create an api server and add public endpoints to it
  2. Setup a Sveltekit application with a vite proxy to point a specific route to the api server
  3. Add a +page.server.ts file and use event.fetch to attempt to access the api via the proxy
  4. Add a hooks.server.ts file and add a cookie to the event
  5. Run both the api and sveltekit applications
  6. Notice when the page is hit it will return an Internal Error

Here is a working reproduction: https://github.com/JLewinski/Reproduction/tree/master

Logs

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics
    Memory: 33.68 GB / 59.67 GB
  Binaries:
    Node: 18.20.8 - C:\nvm4w\nodejs\node.EXE
    npm: 10.8.2 - C:\nvm4w\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (133.0.3065.92)

Severity

Serious, but I can work around it

Additional Information

At the very least it would be good to have a better error message, so developers understand what is going on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions