Skip to content

Svelte 5: dependency tracking issue depending on order of assignment  #9694

@ogheorghies

Description

@ogheorghies

Describe the bug

The following code results in TOO_MANY_UPDATES, as expected, but changing the order to s=v; f(s); does not.

  const v = {value: 1};
  let s = $state(v)

  function f() {}
  function change() {
   f(s); s=v;
  }
  $effect(change);

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE32QsWrEMAyGX0WYGxIoLV1zd4WuHdqhY1OCceSrIZFNJBuC8bvX7sFN5Sah3_o-IWdl3YKshq-sSK-oBvUagnpQsofWcMJFsPbs42ZacmKzuSAvIwEYTyyQ4Aw56SXiAM_l2B4WFOAaH1i0YJf6kVpsIxlxnsB2PeRSQ7lF5kfTBSfxflo17VMMc0W5DTa0wh33R-Bz-tvwL0xe7ggaerVcBdLKAa1FI90dQ9060unpdvdI-e3z4_2RZXN0cXavylK_aPWzsw5nNcgWsXyXX1H-u2NdAQAA

Logs

When using `$effect(change_not_too_many_updates)`:
  Rendered `{"value":1}`, no console message.

When using `$effect(change_too_many_updates)`:
  Rendered `{"value":1}`, console message `Error: ERR_SVELTE_TOO_MANY_UPDATES`.

System Info

svelte: ^5.0.0-next.1 => 5.0.0-next.8

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