sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
76.8k stars 3.98k forks source link

Svelte 5: Chained `$derived`s don't update sometimes #11481

Closed dooshiifox closed 1 week ago

dooshiifox commented 1 week ago

Describe the bug

I know it's not particularly helpful but the reproduction is the best explainer for this. Essentially it seems chaining multiple deriveds causes state to not update even though it should if one of the older derived's value's didn't change. The provided reproduction is as minimal as I could get it with it still occurring.

If you are experiencing this bug, figure out which state isn't updating correctly and try put that last in the $derived block that should be receiving updates but isn't, or reduce the number of $deriveds you're using. $inspect fixes the problem, but remember it won't work in production.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA21SX0_jMAz_KlaEdC2H6Ab3tGuH-AycxMP1HtLWY9HSJIrd7aZp3x2nK1AQT63t3x_b8UltjEVSq78n5XSPaqUeQ1A3io8hBbRHyygx-SG2KVNSG03gde1qtshAWz_Y7mnrD4slVHBFrBmzjbaE-W8BCawo4HkrNsBbQ0CIPYE1OwQNe4xHGFyK7DHV3QuwTxgwTuqt77DRhDeTTsQe-wajQDVDiD7ANf4PEYmMd3QNOqKQ-iB2nUiI1tVth9HsJWysb3c0KZEHwyQWjWHovdDem9BOSkI2bLSVzNjxbeK9DS2K47CTcjZfQj4ZSO0O-oESOqDrwLsLT8t_svYDh-Ftge4HQyvOLzjzuJt7pBfxm8m6qqBWxFH2Vat8RrmfU0aJB0EuawUr-S4-g3_NweN8qfGngw6yBQQfpTa1Cwcfd9MSePT5CdnYy3f66eXL4uNSXBnWp2R4LotwSTQDs2zEu9aadledshyqNWRfzonjgPl5_SemV-B0GotlWVy4oiOH2fvObAx2apWw53_nVz_5oyDTAgAA

Logs

No response

System Info

System:
    OS: Linux 6.6 NixOS 24.05 (Uakari) 24.05 (Uakari)
    CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900HX
    Memory: 17.66 GB / 31.20 GB
    Container: Yes
    Shell: 5.2.26 - /run/current-system/sw/bin/bash
  Binaries:
    Node: 20.11.1 - /nix/store/vz13mi0w75q96sfjxz2ylnv8812hvf34-nodejs-20.11.1/bin/node
    npm: 10.2.4 - /nix/store/vz13mi0w75q96sfjxz2ylnv8812hvf34-nodejs-20.11.1/bin/npm
    pnpm: 8.15.3 - /etc/profiles/per-user/dooshii/bin/pnpm
  Browsers:
    Chromium: 122.0.6261.94
    [Not listed: Firefox DevEdition: 124.0b5]
  npmPackages:
    svelte: 5.0.0-next.123 => 5.0.0-next.123

Severity

annoyance

paoloricciuti commented 1 week ago

Started exploring this: definitely looks like a bug, the moment you access either of der1,der2 or der3 it starts working again.

paoloricciuti commented 1 week ago

It feels like a more elaborate version of #11364 . given that now there are two signals that are unchanged maybe that make a difference?