sveltejs / sveltejs/kit

Remote Functions: Refreshed queries that throw a `redirect` fail

Open
#14,968 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

forms needs-decision
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

Refreshed queries that throw a redirect (while being refreshed inside of a form remote function) cause a 500: Failed to execute remote function error on the client, and an uncaught redirect error ([500] POST / Error: {"status":307,"location":"/reset"}) on the server.

Reproduction
  1. Visit the StackBlitz repro or run git clone https://github.com/AdrianGonz97/sveltekit-refreshed-query-redirect-error
  2. pnpm install && pnpm dev
  3. navigate to / and increment the count to be greater than 5
Logs
[500] POST /
Error: {"status":307,"location":"/reset"}
    at coalesce_to_error (/home/koala/Reproductions/refreshed-query-redirect-error/node_modules/.pnpm/@sveltejs+kit@2.49.0_@sveltejs+vite-plugin-svelte@6.2.1_svelte@5.43.14_vite@7.2.4__svelte@5.43.14_vite@7.2.4/node_modules/@sveltejs/kit/src/utils/error.js:11:5)
    at handle_fatal_error (/home/koala/Reproductions/refreshed-query-redirect-error/node_modules/.pnpm/@sveltejs+kit@2.49.0_@sveltejs+vite-plugin-svelte@6.2.1_svelte@5.43.14_vite@7.2.4__svelte@5.43.14_vite@7.2.4/node_modules/@sveltejs/kit/src/runtime/server/utils.js:86:64)
    at resolve (/home/koala/Reproductions/refreshed-query-redirect-error/node_modules/.pnpm/@sveltejs+kit@2.49.0_@sveltejs+vite-plugin-svelte@6.2.1_svelte@5.43.14_vite@7.2.4__svelte@5.43.14_vite@7.2.4/node_modules/@sveltejs/kit/src/runtime/server/respond.js:705:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async fn (/home/koala/Reproductions/refreshed-query-redirect-error/node_modules/.pnpm/@sveltejs+kit@2.49.0_@sveltejs+vite-plugin-svelte@6.2.1_svelte@5.43.14_vite@7.2.4__svelte@5.43.14_vite@7.2.4/node_modules/@sveltejs/kit/src/runtime/server/respond.js:422:12)
    at async internal_respond (/home/koala/Reproductions/refreshed-query-redirect-error/node_modules/.pnpm/@sveltejs+kit@2.49.0_@sveltejs+vite-plugin-svelte@6.2.1_svelte@5.43.14_vite@7.2.4__svelte@5.43.14_vite@7.2.4/node_modules/@sveltejs/kit/src/runtime/server/respond.js:404:20)
    at async file:///home/koala/Reproductions/refreshed-query-redirect-error/node_modules/.pnpm/@sveltejs+kit@2.49.0_@sveltejs+vite-plugin-svelte@6.2.1_svelte@5.43.14_vite@7.2.4__svelte@5.43.14_vite@7.2.4/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:562:22
System Info
System:
    OS: Linux 6.6 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 22.60 GB / 31.30 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 22.15.0 - /home/koala/.volta/tools/image/node/22.15.0/bin/node
    Yarn: 1.22.22 - /home/koala/.volta/tools/image/yarn/1.22.22/bin/yarn
    npm: 10.9.2 - /home/koala/.volta/tools/image/node/22.15.0/bin/npm
    pnpm: 10.9.0 - /home/koala/.volta/bin/pnpm
    bun: 1.1.38 - /home/koala/.bun/bin/bun
    Deno: 2.1.1 - /home/koala/.deno/bin/deno
  Browsers:
    Chrome: 127.0.6533.119
  npmPackages:
    @sveltejs/adapter-auto: ^7.0.0 => 7.0.0 
    @sveltejs/kit: ^2.49.0 => 2.49.0 
    @sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1 
    svelte: ^5.43.14 => 5.43.14 
    vite: ^7.2.4 => 7.2.4
Severity

annoyance

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the linked reproduction with pnpm install && pnpm dev, open /, and increment count past 5. Start with src/routes/+page.svelte and the server flow shown in runtime/server/respond.js; trace the refreshed query inside the form remote function. Done means the redirect reaches /reset without a client 500 or an uncaught server error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
full-stack
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.