Skip to content

Svelte 5: ERR_SVELTE_TOO_MANY_UPDATES when updating state #9712

@amit13k

Description

@amit13k

Describe the bug

This code leads to ERR_SVELTE_TOO_MANY_UPDATES,

<script>
let x = $state({
	count: 0
});

$effect(() => {
	x.count = 1;
});
</script>

while this doesn't cause any error,

<script>
let x = $state({
	count: 0
});

$effect(() => {
	x = { count: 1 }
});
</script>

Looks like a reactivity bug.

Reproduction

Svelte 5 REPL with Error

Svelte 5 REPL without Error

Logs

No response

System Info

System:
    OS: macOS 14.2
    CPU: (12) arm64 Apple M2 Pro
    Memory: 269.64 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.2.0 - /opt/homebrew/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - /opt/homebrew/bin/npm
    pnpm: 8.11.0 - ~/Library/pnpm/pnpm
    bun: 1.0.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 119.0.6045.199
    Chrome Canary: 121.0.6156.2
    Safari: 17.2

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions