`forkPreloads`: CRASHING SVELTEKIT - a speculative render writes the `UNINITIALIZED` sentinel to the DOM
Describe the bug
I'd like to firstly apologize for the attached AI write-up, but it was able to add more context about the runtime that I couldn't wrap my head around.
forkPreloads: a speculative render writes the UNINITIALIZED sentinel to the DOM
svelte 5.57.0 · @sveltejs/kit 3.0.0-next.27
compilerOptions.experimental.async + kit.experimental.forkPreloads + kit.experimental.remoteFunctions
What happens
Hovering a link throws, before any click:
TypeError: Cannot convert a Symbol value to a string
at to_class
at set_class
at set_attributes
The value is Symbol(uninitialized) — Svelte's own UNINITIALIZED from
src/constants.js. The navigation never completes afterwards, so the link is
dead until the page is reloaded.
Reproduction
Reproduction
A stock SvelteKit app, no third-party dependencies. Load /repro, hover the
link, don't click.
// svelte.config.js
export default {
compilerOptions: { experimental: { async: true } },
kit: { experimental: { forkPreloads: true, remoteFunctions: true } },
};
<!-- src/routes/repro/+page.svelte -->
<a href="/repro/target">hover me</a>
// src/routes/repro/thing.remote.js
import { query } from "$app/server";
export const getThing = query(async () => {
await new Promise((resolve) => {
setTimeout(resolve, 400);
});
return { id: "x" };
});
<!-- src/routes/repro/target/child.svelte -->
<script>
const props = $props();
const klass = (value) => `box ${value}`;
</script>
<button class={klass(props.label)} disabled={props.disabled}>x</button>
<!-- src/routes/repro/target/+page.svelte -->
<script>
import { getThing } from "../thing.remote.js";
import Child from "./child.svelte";
const thing = $derived(await getThing());
let accepted = $state();
</script>
<Child label="a" disabled={accepted === thing.id} />
Cause
src/internal/client/runtime.js already describes the precondition:
In a fork it's possible that a derived is executed and gets reactions, then commits, but is never re-executed. This is possible when the derived is only executed once in the context of a new branch which happens before
fork.commit()runs. In this case, the derived still hasUNINITIALIZEDas its value […]
That handling keeps the derived DIRTY so it re-executes when something reads it.
The DOM attribute writers read the raw .v and write it out before that
re-execution happens.
class is where it fails loudly, because to_class() does '' + value. Other
attributes take the same sentinel through set_attribute() and would stringify
it just as readily — or render something wrong without throwing.
What matters
Removing any one of these makes it stop:
forkPreloadsenabled.classis a call expression.class={fn(x)}throws;class={someProp}andclass={`box ${x}`}are fine. A call compiles to a derived; a bare reference or a template literal is inlined.- The page awaits a remote query. The same page awaiting a plain
Promiseis fine. - Another prop on the child reads the awaited value. A child that doesn't is fine.
Irrelevant: {#if} branches, bind:this, $bindable, {...rest} spreads, and
any component library. The six-line component above is enough.
Worth noting for blast radius: anything that computes its class through a helper
is exposed, which includes every shadcn-svelte component via cn().
Workaround
Three guards — one per path that can write the sentinel. set_attributes is the
spread path; set_attribute and set_class are the non-spread paths.
All three are needed. Guarding only set_attributes still leaves the
reproduction above throwing, because it doesn't spread.
--- a/src/internal/client/dom/elements/attributes.js
+++ b/src/internal/client/dom/elements/attributes.js
@@ export function set_attribute(element, attribute, value, skip_warning) {
+ if (value === UNINITIALIZED) return;
+
var attributes = get_attributes(element);
@@ function set_attributes(
let value = next[key];
+ // A forked render can read a derived from the other batch before it has
+ // been evaluated and receive this sentinel instead of a value. It must
+ // never reach the DOM.
+ if (value === UNINITIALIZED) continue;
+
// Up here because we want to do this for the initial value, too [...]
--- a/src/internal/client/dom/elements/class.js
+++ b/src/internal/client/dom/elements/class.js
@@
+import { UNINITIALIZED } from '../../../../constants.js';
import { to_class } from '../../../shared/attributes.js';
@@ export function set_class(dom, is_html, value, hash, prev_classes, next_classes) {
+ if (value === UNINITIALIZED) return;
+
var prev = /** @type {any} */ (dom)[CLASS_CACHE];
This only stops the throw. It does not stop a derived being read before it is evaluated, so the real fix presumably belongs wherever the fork performs that read.
One note on the REPL
This can't be reduced to a playground link. forkPreloads is a SvelteKit option
and the fork is driven by the router's hover-preload, and the playground has no
router. Calling fork() directly in plain Svelte doesn't reproduce it either —
a fork's changes stay speculative until .commit(), so nothing renders.
Logs
System Info
N/A
Severity
blocking all usage of SvelteKit
Additional Information
No response
I could not reproduce the reported behavior from the instructions currently available.
What I tried
- Read "https://github.com/sveltejs/kit/issues/17093", its comments, repository AGENTS.md/CONTRIBUTING.md, and inspected current Kit/Svelte runtime code and fork tests.: Issue is open with no comments. Kit checkout was version-3 at 4da6320; the async test app resolves Svelte 5.57.0 and already enables compiler async, remoteFunctions, and forkPreloads.
- Added the reported route verbatim to packages/kit/test/apps/async: delayed 400 ms remote query, awaited $derived, second prop reading thing.id, and child class={klass(props.label)}. Added a Playwright test collecting pageerror events, hovering the link, awaiting the remote response, clicking, and asserting class "box a".: The reduced fixture exercised an actual /_app/remote/ response during hover. No page error was observed, navigation completed, and the rendered button had the expected class.
- Ran DEV=true KIT_E2E_PROJECT=js npx playwright test test/client.test.js --grep "hover-preloading an awaited remote query" after pointing Kit's configured Chrome channel at the sandbox's installed Playwright Chromium.: 1 test passed in development mode; the reported Symbol(uninitialized) exception did not occur.
- Ran KIT_E2E_PROJECT=js npx playwright test test/client.test.js --grep "hover-preloading an awaited remote query" without DEV.: 1 test passed against the production build/preview; preload and subsequent navigation remained usable.
- Ran the same development-mode reproduction with --repeat-each=20 --workers=1 to check for timing sensitivity around the delayed query.: 20/20 runs passed in 40.5 seconds. Every run awaited the hover-triggered remote response and observed no pageerror.
- Removed the temporary reproduction and test, then ran git status --short --branch and git diff --check.: The Kit working tree is clean on triage/kit-17093-fork-preload-uninitialized; no product code was changed, committed, or pushed.
Observed blocker The exact reported configuration and component/query structure did not reproduce on the current default Kit checkout with its installed Svelte 5.57.0, in either development or production mode, including 20 repeated timing-sensitive development runs. Because the sentinel never reached the DOM writers and navigation consistently succeeded, a product patch would be speculative.
Encountered the bug too.
With the Svelte compiler's experimental.async enabled (required by remote
functions) and SvelteKit's experimental.forkPreloads enabled, the following
sequence crashes the entire application to the error page:
- The current page's remote
query()rejects and the page renders its handled error state (readingquery.error— the failure is graceful). - The user hovers a link (
data-sveltekit-preload-data="hover"), forking a preload render. - The forked render is abandoned; an attribute that was pending resolution in that fork (here: the
idof abits-uiCollapsibletrigger) is then applied to the live DOM as Svelte's internal placeholder:setAttribute('id', Symbol(uninitialized))→TypeError: Cannot convert a Symbol value to a string. - The throw happens in an update effect during a flush, so
<svelte:boundary>does not catch it; the app is replaced by the500 | Internal Errorpage.
Environment
- svelte 5.57.2
- @sveltejs/kit 3.0.1
- @sveltejs/vite-plugin-svelte 7.3.1
- vite 8.3.4
- bits-ui 2.19.5 (supplies the affected
Collapsibletrigger; likely not essential — any attribute that resolves during the fork should do) - Linux; reproduced by the app team in normal desktop browsers and verified automatically in headless Chromium 115 (Playwright)
- Date: 2026-10-11