sveltejs / svelte · Issue No. 18615
Reactive values referenced inside a labeled statement are not transformed during SSR.
Svelte Code
<script>
let value = $derived(false);
let result = "correct";
label: if (value) result = "wrong";
</script>
<p>{result}</p>
SSR compiled code
import 'svelte/internal/flags/async';
import * as $ from 'svelte/internal/server';
export default function App($$renderer) {
let value = $.derived(() => false);
let result = "correct";
label: if (value) result = "wrong";
$$renderer.push(`<p>${$.escape(result)}</p>`);
}
The client compiler correctly unwraps the derived value:
label: if ($.get(value)) result = 'wrong';
The server compiler does not:
label: if (value) result = 'wrong';
Because $.derived() returns a function on the server, value is always truthy. As a result, SSR renders wrong while CSR renders correct.
@MathiasWP and I found this issue while implementing rsvelte.
https://github.com/baseballyama/rsvelte/pull/2269
System:
OS: macOS 26.6
CPU: (12) arm64 Apple M4 Pro
Memory: 112.27 MB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.13.1 - /Users/baseballyama/.nodenv/versions/24.13.1/bin/node
npm: 11.8.0 - /Users/baseballyama/.nodenv/versions/24.13.1/bin/npm
pnpm: 11.20.0 - /Users/baseballyama/.nodenv/versions/24.13.1/bin/pnpm
bun: 1.3.11 - /opt/homebrew/bin/bun
Deno: 2.5.6 - /opt/homebrew/bin/deno
annoyance
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.