sveltejs / sveltejs/kit

Redirect and single-flight mutations

Open
#15,726 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

When a remote form function rehreshes a query and then redirects, the query is fetched again after the redirect (if it is used on that page). I would have exptected it to use the fresh data retured from the form function after the redirect. If not, I guess there is no way to do single-flight mutation when using redirect.

Reproduction

https://www.sveltelab.dev/5uaeob2ogwsg968?files=.%2Fsrc%2Flib%2Fdata.remote.js

  1. Click edit
  2. Submit the form
  3. Notice the network traffic:
remote (contains data):
refreshes: "[{\"1t2evzh/data/\":1},{\"type\":2,\"data\":3},\"result\",3]"

data (is fetched anyway):
result: "[3]"
type: "result"
Logs

System Info
System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 22.22.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.3.1 
    @sveltejs/kit: ^2.5.27 => 2.57.1 
    @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.1.1 
    svelte: ^5 => 5.55.4 
    vite: ^6.0.0 => 6.4.2
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

Start with the linked SvelteLab reproduction and inspect src/lib/data.remote.js, then observe the network sequence when the form refreshes a query and redirects. Trace how the refreshed data is handled across the redirect. Done means the redirected page reuses the fresh form data instead of fetching the query again.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.