Closed
Description
Describe the bug
Previously, in Svelte 4, you used to be able to set a variable to undefined
and later set it to a store and meanwhile use it in reactive statements. While not ideal, this used to work.
In svelte 5 if you do something similar it'll throw the state_unsafe_mutation
error. See reproduction below. It's probably right to error in this case, but the error is very misleading we spent hours trying to track it down yesterday 😅
Maybe for some context, our before / after:
Before
const prs = $derived($hostedListingServiceStore?.prs);
const listedPr = $derived($prs?.find((pr) => pr.sourceBranch === branch.upstreamName));
After
const prStore = $derived($hostedListingServiceStore?.prs);
const prs = $derived(prStore ? $prStore : undefined);
const listedPr = $derived(prs?.find((pr) => pr.sourceBranch === branch.upstreamName));
Reproduction
Logs
No response
System Info
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels