`Fetch after load has returned` uneeded warning
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
When doing two sequential fetch calls on +page.sever.ts in a streammed promise I get a warning
src/routes/+page.server.js: Calling `event.fetch(...)` in a promise handler after `load(...)` has returned will not cause the function to re-run when the dependency is invalidated
However this warning is unneeded as both call are inside an async function that will only return after both requests are done.
Reproduction
Here is the relevant code:
export const load = async ({ fetch }) => {
return {
character: loadData(fetch),
};
};
async function loadData(fetch) {
const res1 = await fetch('https://rickandmortyapi.com/api/character');
const charList = await res1.json();
console.log('Fetched char list with size ->', charList.results.length);
const res2 = await fetch(charList.results[0].url);
const char = await res2.json();
console.log('Fetched first Char -> ', char.name);
return char;
}
The warning will happen between the two console.log() but as explained before the function will only return after both calls are done thus I believe that the warning is not needed, as nothing was returned before the calls are done and thus there was no expectation regarding re-runs.
This also seems to happen if there is a Promise.all() with multiple fetchs.
Logs
Fetched char list with size -> 20
src/routes/+page.server.js: Calling `event.fetch(...)` in a promise handler after `load(...)` has returned will not cause the function to re-run when the dependency is invalidated
Fetched first Char -> Rick Sanchez
System Info
System:
OS: Linux 6.11 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900K
Memory: 17.41 GB / 31.05 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
pnpm: 10.8.1 - ~/.local/share/pnpm/pnpm
Browsers:
Chrome: 136.0.7103.92
npmPackages:
@sveltejs/adapter-auto: ^6.0.1 => 6.0.1
@sveltejs/kit: ^2.21.0 => 2.21.0
@sveltejs/vite-plugin-svelte: ^5.0.3 => 5.0.3
svelte: ^5.28.6 => 5.28.6
vite: ^6.3.5 => 6.3.5
Severity
annoyance
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction's src/routes/+page.server.js and its load function, then run the linked StackBlitz example to observe the warning between the two fetch calls. Trace the event.fetch warning behavior for sequential and Promise.all calls; done means valid async load work no longer produces this warning while invalidation behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100