Skip to content

$effect Infinite Loop Error (effect_update_depth_exceeded) #15398

@lilacbora

Description

@lilacbora

Describe the bug

While developing with Svelte 5, an infinite loop occurred due to using $state inside $effect.
When clicking the button in the example, the console in the developer tools logs multiple times before throwing the 'effect_update_depth_exceeded' error.
The issue occurs when both No.1 and No.2 are present, but if either one is commented out, the infinite loop does not happen.
Is this a bug in Svelte 5?
If it's not a bug, I would like to understand why the reactivity of b is triggered, causing the infinite loop.

Reproduction

https://svelte.dev/playground/hello-world?version=5.20.4#H4sIAAAAAAAACn2RT2vDMAzFv4rQCk2gJGzH_IPddtplx3kUJ1YyM9cOsbJ1ZPnuw01DCyvzxejpZz2jN6GVB8IMn8gYB19uMAoiUppJxbjDVhvymL1OyN994IKAu_XVY98n_pMMB62Wnm7pjbNMlj1mWPhm0D2DkbYrBbIXWAkr2BCDhBI2niVT1ErjKc4Fr7360pu0ymAKPhmMVlGrLSmQHjwP2nbwc1HnOc6FDTM21LbUcBTFUFYwBUmwbiMZr4XgNIWF2o-9kkx7RT2_7-nYEKkVqhOtoPzjP-cAaQrPLrm_JpOAQQkCmTwLzM_Qwwo1znpnKDGui7Z312d7-vpNCHgYCf5nbgyaw3XaSJEuMVTCFvXI7CyEdEuBSyUQnG2Mbj7K6byxEE6wnefqRR56Q0W6sJWwuEOmI2N2At7mX9OVV5JUAgAA

Logs

System Info

svelte 5.20
sveltejs/kit 2.17.0
sveltestrap 7.1.0

Severity

annoyance

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