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

svelte 5 : structural clone failed #12438

Closed
zhihengGet opened this issue Jul 14, 2024 · 2 comments · Fixed by #12445
Closed

svelte 5 : structural clone failed #12438

zhihengGet opened this issue Jul 14, 2024 · 2 comments · Fixed by #12445
Milestone

Comments

@zhihengGet
Copy link

Describe the bug

clone.js:53  Uncaught (in promise) DOMException: Failed to execute 'structuredClone' on 'Window': () => {
  } could not be cloned.

here is my repo for lexical svelte 5 port

https://github.com/zhihengGet/lexical-svelte

if you update svelte to 5.0.0-next.184 then it breaks, works in 183 , im not using $state.snapshot anywhere in the code

Reproduction

https://github.com/zhihengGet/lexical-svelte, main branch, then update svelte to 184 and run bun dev

Logs

No response

System Info

windows 11

Severity

blocking an upgrade

@dummdidumm dummdidumm added this to the 5.0 milestone Jul 14, 2024
@henrikvilhelmberglund
Copy link

Editor.svelte line 57
$inspect('setting change', settings());
This breaks it, uncomment it for it to at least load (still a bunch of other things that cannot be cloned).
Also please make a smaller repro.

@zhihengGet
Copy link
Author

zhihengGet commented Jul 14, 2024

ahh ok , i thought only $state.snapshot uses it , but i guess $inspect is using clone too, this can be closed if this is the case!

dummdidumm added a commit that referenced this issue Jul 15, 2024
Snapshotting can error on un-cloneable objects. It's not practical to error in this case; often there's no way out of this for users, so it makes sense to return the original value in that case, and warn in dev mode about it.

closes #12438
Rich-Harris added a commit that referenced this issue Jul 16, 2024
* fix: ensure `$state.snapshot` never errors

Snapshotting can error on un-cloneable objects. It's not practical to error in this case; often there's no way out of this for users, so it makes sense to return the original value in that case, and warn in dev mode about it.

closes #12438

* lint

* single warning per snapshot call, list affected properties

* lint

* lint

---------

Co-authored-by: Rich Harris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants