Skip to content

Commit 6588d85

Browse files
authored
chore: rewrite state_unsafe_mutation message (#12059)
1 parent 0ef906c commit 6588d85

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

.changeset/nasty-glasses-begin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: rewrite state_unsafe_mutation message

packages/svelte/messages/client-errors/errors.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@
6666
6767
## state_unsafe_mutation
6868

69-
> 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.
70-
>
71-
> If the object is not meant to be reactive, declare it without `$state`
69+
> Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state`
7270
7371
## svelte_component_invalid_this_value
7472

packages/svelte/src/internal/client/errors.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,12 @@ export function state_prototype_fixed() {
279279
}
280280

281281
/**
282-
* 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.
283-
*
284-
* If the object is not meant to be reactive, declare it without `$state`
282+
* Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state`
285283
* @returns {never}
286284
*/
287285
export function state_unsafe_mutation() {
288286
if (DEV) {
289-
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`"}`);
287+
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`"}`);
290288

291289
error.name = 'Svelte error';
292290
throw error;

0 commit comments

Comments
 (0)