Skip to content

Reactive Set .size not updated after .delete() #11952

@hanszoons

Description

@hanszoons

Describe the bug

The .size property of a reactive Set is not reliable, does not update when items are deleted like a native Set.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE42Ry2rDMBBFf2XQxjaImr4WSdNCv6HLJAvHum4ElsZI47Sp8b8XOUmbQhu6EGhG5z5Ag2psi6jmy0H5ykHN1XPXKa1k36Uh7tAKlFaR-1CnzSLWwXbytPIrKUuq2Tl4Ie6FZAuyruMgJEwRmDZ471ALDG2wrXaW-0DWTy81-8gtktNRNtALhEZqAjvKDuFlQFWL3VnZZw8rn-gkFPK92yBEeiSPtyTMl9eabjTdarrTdL8uznBucdXya55F-wHaoOEAMmghln3M9Mnt63KVwCLJ02k4UH4eS9ycyIKGCZOTcrJFfhinEvKzxO9ZEzj-VblqBOF_jf13lcqYfDYrLptWxlywW5THH1daOTa2sTBqLqHHuB4_AVoEAzZAAgAA

If you comment out the reactive Set import, you see the console log counting down on each iteration. With the reactive Set enabled, the size property stays the same throughout and after the loop. The size is correct again after doing an .add()

Logs

No response

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 223.81 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
    pnpm: 8.9.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 125.0.6422.142
    Safari: 17.5
  npmPackages:
    svelte: ^5.0.0-next.151 => 5.0.0-next.151

Severity

blocking all usage of svelte

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