Skip to content

Svelte 5: next.28 -> next.29 $state array bug #10120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dm-de opened this issue Jan 8, 2024 · 7 comments
Closed

Svelte 5: next.28 -> next.29 $state array bug #10120

dm-de opened this issue Jan 8, 2024 · 7 comments
Assignees
Milestone

Comments

@dm-de
Copy link

dm-de commented Jan 8, 2024

Describe the bug

something changed between next.28 -> next.29
$state is now defect

I found 2 issues:

  1. inserted objects to state array are not the same
    You can see this in example, because delete in setTimeout does not work

  2. after insertig some items and removing them all (click on toast to remove),
    here are some issues adding new items... they don't show up or they show up after many clicks.

Reproduction

next.28 working
next.29 not working

LINK

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
    Memory: 9.19 GB / 15.96 GB
  Binaries:
    Node: 21.2.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (120.0.2210.121)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    svelte: ^5.0.0-next.29 => 5.0.0-next.29

Severity

annoyance

@Conduitry
Copy link
Member

This sounds like #10118 - is it the same issue?

@dm-de
Copy link
Author

dm-de commented Jan 8, 2024

You are right - it is the same!

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2024
@dm-de
Copy link
Author

dm-de commented Jan 9, 2024

This bug (issue 1) is not fixed by #10121

@trueadm
Copy link
Contributor

trueadm commented Jan 9, 2024

Ah yes, sorry. So many issues I was working on linked back to this one, so I must have tagged this from that.

@dummdidumm
Copy link
Member

dummdidumm commented Jan 19, 2024

Mhm I don't think there's anything we can do here. When the object is added to the array, it's proxified, so the comparison is now between a proxy of the item and the item, which returns false.
Side note: I wonder if it's possible to avoid adding a symbol onto the original object and only add that to the proxy instead (so that the original object isn't polluted by the proxy stuff)

@dm-de
Copy link
Author

dm-de commented Jan 20, 2024

Mhm I don't think there's anything we can do here.

This is then a breaking change!
In the case that it is not changed and stays that way:

  1. Please add this to: https://svelte-5-preview.vercel.app/docs/breaking-changes
  2. Please add note at https://svelte-5-preview.vercel.app/docs/runes#$state
    That adding non-proxy objects to $state-arrays create new proxy objects

@dummdidumm
Copy link
Member

Closing in favor of #11556 which tracks documenting this on the site. #11610 will help surfacing this situation better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants