Skip to content

Svelte 5: $effect is unusable (produce circular dependencies and endless updates) #14119

@go-aegian

Description

@go-aegian

Describe the bug

At this point when converted to $effect all code broke even after some variables changes to become reactive, the reactive block enters in endless loop, I cannot even explain the frustation of having not only my app broken but many community libs that fails due to these changes when the app uses runes and libs start to fail to even compile, causing a cascade of problems throughout.

The $effect should behave the same way as $: { }, otherwise it forces to change previously working reactive code and makes it not as straightforward change due to $state, $derived and when variables are evaluated even the ones coming from $props it fails as most of them come as $proxy, it's a this point forcing to trace how a variable was declared on each statement and also like @TGlide pointed out, it triggers on a counter updated inside which can be overcame yet still is not intuitive and the trade of overly complicated way for fancier but unusable or just say extremely cumbersome how to use it, makes it not as simpler as svelte was supposed to be as before. Hopefully you guys can rethink when introducing language changes like this you think of steps to port after having a compiler for a decade to force all the community to change in a very strange way no matter how good the improvements are still we were not considered on what the effort and damage these changes caused on apps or libs that were working and were being maintaned.

Reproduction

Any code that previously worked with reactive variables in a $: now is a headache to port plus the onMount still works but some docs describes to use $effect instead as it works for both reactive and on mounting

Logs

No response

System Info

Svelte 5

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