Skip to content

svelte 5 bug: class getters rerun when non-dependent state updates #11218

@anatolzak

Description

@anatolzak

Describe the bug

If you have a class with a method and a getter, whenever a non-dependent state changes outside of the class, the getter will rerun but the method won't. I don't expect the getter to rerun if it doesn't doesn't access any reactive state from inside the getter. A class method doesn't rerun unless it accesses a reactive variable inside that changed.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE32Q3UrEMBCFXyUEYVssq97WtiA-hvWiptMaNp0pyXQXCX13SdMfQfQmkHPON5kcLzttwMn8zUtsBpC5fBlHmUn-GsPFXcEwyEw6mqwKSuGU1SNXNdZsgIWiCVmU4s5xw5A8ps81Bq-bULEmFBqVhQGQk1T44NQcmftSPIUwz5FQpnFOvNIwEgLyFu6BBSEcdODRkYGzoT459cAM9pRupgWeLIpNj_K8usvJN_pz2gD8Se3vaav-Y9q2NaELLWxblwLhdvwiSWssHo7OsPiYmAkFoTJaXUq_9zNXsQWtLi4XfilpDnQkIt3qa3WU5fd3z4SwhNfAP8nl-3tWZnKgVncaWpmznWB-n78BIJjDhRYCAAA=

Logs

No response

System Info

System:
    OS: macOS 14.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 3.94 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - /usr/local/bin/node
    npm: 10.5.0 - /usr/local/bin/npm
    pnpm: 8.11.0 - /usr/local/bin/pnpm
    bun: 1.1.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 120.0.6099.109
    Edge: 114.0.1823.82
    Safari: 17.3
  npmPackages:
    svelte: 5.0.0-next.107 => 5.0.0-next.107

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