sveltejs/kit · warning
${node.server_id}: Calling `event.fetch(...)` in a promise h
Error message
${node.server_id}: Calling `event.fetch(...)` in a promise handler after `load(...)` has returned will not cause the function to re-run when the dependency is invalidated What it means
SvelteKit warns when `event.fetch` is called inside a promise handler after the `load` function has returned, targeting a URL that was never fetched during the tracked portion of `load`. Such late fetches are not registered as dependencies, so invalidating them will not re-run `load`.
Source
Thrown at packages/kit/src/runtime/server/page/load_data.js:91
const result = await record_span({
name: 'sveltekit.load',
attributes: {
'sveltekit.load.node_id': node.server_id || 'unknown',
'sveltekit.load.node_type': get_node_type(node.server_id),
'sveltekit.load.environment': 'server',
'http.route': event.route.id || 'unknown'
},
fn: async (current) => {
const traced_event = merge_tracing(event, current);
const result = await with_request_store({ event: traced_event, state }, () =>
load.call(null, {
...traced_event,
fetch: (info, init) => {
const url = new URL(info instanceof Request ? info.url : info, event.url);
if (DEV && done && !uses.dependencies.has(url.href)) {
console.warn(
`${node.server_id}: Calling \`event.fetch(...)\` in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the dependency is invalidated`
);
}
// Note: server fetches are not added to uses.depends due to security concerns
return event.fetch(info, init);
},
/** @param {string[]} deps */
depends: (...deps) => {
for (const dep of deps) {
const { href } = new URL(dep, event.url);
if (DEV) {
validate_depends(node.server_id || 'missing route ID', dep);
if (done && !uses.dependencies.has(href)) {
console.warn(
`${node.server_id}: Calling \`depends(...)\` in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the dependency is invalidated`View on GitHub (pinned to 03f1687fe6)
Solutions
- Move all `event.fetch` calls into the synchronous (pre-await) portion of `load`.
- Pre-fetch any URLs you will need before returning, or use `depends()` synchronously to declare the dependency.
- Restructure so dependent fetches are sequenced with `await` inside the load body.
Example fix
// before
export function load({ fetch }) {
return fetch('/a').then(() => fetch('/b'));
}
// after
export async function load({ fetch }) {
await fetch('/a');
const b = await fetch('/b');
return { b };
} Defensive patterns
Strategy: validation
Validate before calling
export async function load({ fetch }) {
// fetch everything before returning; no fetch after the first return/await-chain tail
const a = await fetch('/api/a').then((r) => r.json());
const b = await fetch('/api/b').then((r) => r.json());
return { a, b };
} Prevention
- Keep all `event.fetch` calls inside the synchronous/awaited load body.
- Avoid fire-and-forget fetches in `load`; they are untracked.
- Declare dependent resources with `depends()` up front if fetches must be conditional.
When it happens
Trigger: Server `load` defers work in a `.then()`/post-await continuation and calls `event.fetch('/api/x')` there, where `/api/x` was not among `uses.dependencies` gathered during the synchronous run.
Common situations: Chained fetches where a second `event.fetch` happens in the `then` of the first; background prefetching after load returns.
Related errors
- ${node.server_id}: Accessing URL properties in a promise han
- ${node.server_id}: Calling `depends(...)` in a promise handl
- ${node.server_id}: Accessing `params.${String(key)}` in a pr
- ${node.server_id}: Calling `parent(...)` in a promise handle
- ${node.server_id}: Accessing `route.${String(key)}` in a pro
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/e205f8709ad8a9d4.
Report an issue: GitHub.