diff --git a/.changeset/nasty-glasses-begin.md b/.changeset/nasty-glasses-begin.md new file mode 100644 index 000000000000..7a7621b2ecb8 --- /dev/null +++ b/.changeset/nasty-glasses-begin.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: rewrite state_unsafe_mutation message diff --git a/packages/svelte/messages/client-errors/errors.md b/packages/svelte/messages/client-errors/errors.md index ec543765cfc9..3e64b9089982 100644 --- a/packages/svelte/messages/client-errors/errors.md +++ b/packages/svelte/messages/client-errors/errors.md @@ -66,9 +66,7 @@ ## state_unsafe_mutation -> Unsafe mutations during Svelte's render or derived phase are not permitted in runes mode. This can lead to unexpected errors and possibly cause infinite loops. -> -> If the object is not meant to be reactive, declare it without `$state` +> Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state` ## svelte_component_invalid_this_value diff --git a/packages/svelte/src/internal/client/errors.js b/packages/svelte/src/internal/client/errors.js index 232cc2eeee2c..e344c552da06 100644 --- a/packages/svelte/src/internal/client/errors.js +++ b/packages/svelte/src/internal/client/errors.js @@ -279,14 +279,12 @@ export function state_prototype_fixed() { } /** - * Unsafe mutations during Svelte's render or derived phase are not permitted in runes mode. This can lead to unexpected errors and possibly cause infinite loops. - * - * If the object is not meant to be reactive, declare it without `$state` + * Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state` * @returns {never} */ export function state_unsafe_mutation() { if (DEV) { - const error = new Error(`${"state_unsafe_mutation"}\n${"Unsafe mutations during Svelte's render or derived phase are not permitted in runes mode. This can lead to unexpected errors and possibly cause infinite loops.\n\nIf the object is not meant to be reactive, declare it without `$state`"}`); + const error = new Error(`${"state_unsafe_mutation"}\n${"Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state`"}`); error.name = 'Svelte error'; throw error;