svelte: False positive `ownership_invalid_binding`?

Describe the bug

I’m getting the following message, telling me to consider bind: between the two components. However, I am, in fact, binding between the two.

CleanShot 2024-10-14 at 22 02 50@2x

Reproduction

https://svelte.dev/playground/c27c1016f1f2423489568d9fb2271921?version=5.2.5

Logs

[svelte] ownership_invalid_bindingsrc/lib/calendar-with-select.svelte passed a value to node_modules/.pnpm/bits-ui@1.0.0-next.17_svelte@5.0.0-next.265/node_modules/bits-ui/dist/bits/calendar/components/calendar.svelte with `bind:`, but the value is owned by node_modules/.pnpm/bits-ui@1.0.0-next.17_svelte@5.0.0-next.265/node_modules/bits-ui/dist/bits/calendar/components/calendar.svelte. Consider creating a binding between node_modules/.pnpm/bits-ui@1.0.0-next.17_svelte@5.0.0-next.265/node_modules/bits-ui/dist/bits/calendar/components/calendar.svelte and src/lib/calendar-with-select.svelte

System Info

System:
    OS: macOS 15.0
    CPU: (12) arm64 Apple M2 Max
    Memory: 92.23 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.15.1/bin/npm
    pnpm: 9.6.0 - ~/Library/pnpm/pnpm
    bun: 1.0.25 - ~/.bun/bin/bun
  Browsers:
    Edge: 129.0.2792.89
    Safari: 18.0
  npmPackages:
    svelte: ^5.0.0-next.1 => 5.0.0-next.265

Severity

annoyance

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 11
  • Comments: 17 (6 by maintainers)

Commits related to this issue

Most upvoted comments

This has nothing to do with Tauri.

It is a general svelte issue when you bind to an object, and then perform a hot reload on the component that has the bindable props.

I have made a minimal repro here: https://github.com/F2/svelte-bug-ownership_invalid_mutation

In the video here, you can see that entering text into the textbox does not throw any warnings. But after a hot reload, it starts throwing warnings.

https://github.com/user-attachments/assets/97591388-8786-425c-aa66-a77fca96ba42

i am using Tauri and getting this bug even when using this example from svelte playground. For some reason, there is no this warnings in firefox 134.0 and chromium 131.0. Image

Are you sure you are literally only using that example? I think we need an actual reproduction

I rechecked it and it happens only in tauri when the code is hot reloaded. If you change any code fragment and open the console after hot-reloading, you will get these warnings. And it seems there are no problems with a full restart. It seems to have something to do with tauri, because I can’t get this behavior in browsers

So, I was able to reproduce it, but I’m not sure if it’s the same reproduction as in this issue.

Here’s a REPL

This happens when state is stored in a separate file from where it was declared/instantiated. I hope REPL will make it clear enough.

I wonder if it’s actually a ‘legit’ svelte coding pattern…

Isn’t one of the intended benefits of Svelte 5 runes that you can store state in any non-svelte component and use it elsewhere? If this isn’t the intended behavior, what would be the correct way to distribute components that take state as props and modify them?

Thanks for the REPL repro @someone2080 ! That’s exactly when it appears to be happening when it shouldn’t.

So, I was able to reproduce it, but I’m not sure if it’s the same reproduction as in this issue.

Here’s a REPL

This happens when state is stored in a separate file from where it was declared/instantiated. I hope REPL will make it clear enough.

I wonder if it’s actually a ‘legit’ svelte coding pattern…