Skip to content
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

can't define property Symbol("$state"): Object is not extensible #11887

Closed
laszlokorte opened this issue Jun 3, 2024 · 0 comments · Fixed by #11889
Closed

can't define property Symbol("$state"): Object is not extensible #11887

laszlokorte opened this issue Jun 3, 2024 · 0 comments · Fixed by #11889
Assignees
Labels
Milestone

Comments

@laszlokorte
Copy link

Describe the bug

Frozen objects can not be written into a $state().

If for example some external library creates objects that are frozen, these objects can not be written into a svelte $state since [email protected] because the proxy tries to extend the value object or array with additional properties.

This prevents to use such external libraries in combination with svelte, especially if the objects in questions are not easily cloneable/unfreezable - for example nested objects and arrays containing DOM nodes.

My concrete use-case is the partial.lenses library. Its an optics library that can be used to read and updated nested objects. It freezes all new objects by default. These objects can then not be stored inside a $state. It did however work until [email protected]

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACo1Ty2rDMBD8FSEKcSA4d5MESiFQKBR6rXtQ7HWqIq-EtE7bGP97JfnRmEDIwQ-tZkaz43XLK6nA8ey95Shq4Bl_NIavOP2asHAnUAR-7XRji1DZuMJKQ7sccyo0OmJKHvYW4Azu9fAFBTm2ZWQbCIhwVQ0WJDUyp2t48eBh_WRBkMTj3mp9BuzJyUmoBpasjWySVXIlP23mZIEai6zfSKsIS1qJCDZjUalb9tiOgXJwxZxjB2h4hNsN72-R7s0_B37ybYUxUE7OBvWhnMZDRtV5JoJ0nUiU5EPDRqlJQgF5y7764EiQ7ypazO4LMQgux9ZnlqYAjl4_SiYXeU6w2-2CSvvPNPK61fjmJtnTTHek-IbuG4Mr7W4WoOrP8XIxwcUnKKUXnrRZ_w8obiSahlgY5m3OCX4o5-wgscyimW0ItffVsXXPcEbg7qLu9ULF_wK1LmUloeRZmO7uo_sDJ_qskT0DAAA=

Logs

Uncaught TypeError: can't define property Symbol("$state"): Array is not extensible

  in App.svelte
    proxy proxy.js:63
    set proxy.js:297
    App App.svelte:422

System Info

[email protected]
Firefox 126.0.1

Severity

blocking an upgrade

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

Successfully merging a pull request may close this issue.

3 participants