Skip to content

forkPreloads: preloading a page calls its remote query once with undefined (and twice with the right argument) #17370

Description

@aaisino

Describe the bug

kit-fork-repro.zip

Describe the bug

With experimental.forkPreloads enabled, preloading a page whose component awaits a parameterised remote query sends that query three times: twice with the right argument and once with no argument at all. With a schema on the query, the argument-less call fails validation on the server ("Remote function schema validation failed: … received undefined").

It looks as if the forked render briefly runs the new page with the previous route's params (no slug), then again with the new ones.

In our app the failed call didn't stay invisible. A phone tap preloads on touchstart and then navigates, and the navigation then showed the error page instead of the course page. We saw this across the site until we turned forkPreloads off.

Without forkPreloads, a hover sends nothing, and the click sends exactly one request with the right argument.

Reproduction

A minimal project (attached zip, 4 source files):

src/routes/items/data.remote.ts

import * as v from 'valibot';
import { query } from '$app/server';

export const getItem = query(v.string(), async (slug) => ({ name: slug }));

src/routes/items/[slug]/+page.svelte

<script lang="ts">
	import { getItem } from '../data.remote.ts';

	let { params } = $props();
	const item = $derived(await getItem(params.slug));
</script>

<h1>{item.name}</h1>

src/routes/+page.svelte

<a href="/items/foo">foo</a>

vite.config.ts

sveltekit({
	compilerOptions: { experimental: { async: true } },
	adapter: adapter(),
	experimental: { remoteFunctions: true, forkPreloads: true }
})

app.html has <body data-sveltekit-preload-data="hover">.

Steps:

  1. bun install.
  2. bunx svelte-kit sync.
  3. bun --bun vite build.
  4. PORT=4390 bun ./build.
  5. Open /, hover the link for about a second, then click it.

(probe.ts in the zip does this with Playwright and prints the remote requests.)

Remote requests with forkPreloads: true:

after hover:
getItem payload=["foo"]
getItem payload=["foo"]
getItem payload=(none)        ← server: "Remote function schema validation failed … input: undefined"
after click:
(none — the preloaded fork is used)

The same project with forkPreloads: false:

after hover:
(none)
after click:
getItem payload=["foo"]

Expected behaviour

The forked render of the preloaded page runs only with that page's own params. Each query is requested once, the same as without forks.

System info

  • @sveltejs/kit 3.0.1
  • svelte 5.57.1
  • vite 8.3.3
  • @sveltejs/vite-plugin-svelte 7.3.1
  • @sveltejs/adapter-bun 1.0.0
  • valibot 1.5.0
  • Bun 1.4.2 (Linux x64)
  • Chromium (Playwright 1.63)

Severity

Annoyance. It breaks navigation in production with forkPreloads on, but that is an experimental flag and we have turned it off.

Reproduction

kit-fork-repro.zip

Logs

System Info

System:
    OS: Linux 6.18 Ubuntu 24.04.5 LTS 24.04.5 LTS (Noble Numbat)
    CPU: (4) x64 Intel(R) Xeon(R) Processor @ 2.10GHz
    Memory: 14.70 GB / 15.72 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 22.22.0 - /opt/node22/bin/node
    npm: 10.9.4 - /opt/node22/bin/npm
    bun: 1.4.2 - /root/.bun/bin/bun
  Browsers:
    Chromium: 141.0.7390.37 (Playwright 1.63, headless)
  npmPackages:
    @sveltejs/adapter-bun: 1.0.0 => 1.0.0
    @sveltejs/kit: 3.0.1 => 3.0.1
    @sveltejs/vite-plugin-svelte: 7.3.1 => 7.3.1
    svelte: 5.57.1 => 5.57.1
    vite: 8.3.3 => 8.3.3

Severity

serious, but I can work around it

Additional Information

No response

Activity

  1. jvz-devx commented on Oct 9, 2026

    @jvz-devx

    I am also experiencing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions