Skip to content

From svelte@5.5.2 a lot of reactive_declaration_non_reactive_property warnings #14532

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
frederikhors opened this issue Dec 3, 2024 · 12 comments · Fixed by #14663
Closed

From svelte@5.5.2 a lot of reactive_declaration_non_reactive_property warnings #14532

frederikhors opened this issue Dec 3, 2024 · 12 comments · Fixed by #14663
Labels

Comments

@frederikhors
Copy link

frederikhors commented Dec 3, 2024

Describe the bug

From svelte@5.5.2 I get a lot (I mean A LOT) of these warnings in browser console:

A `$:` statement (node_modules/​.pnpm/​svelte-select@5.8.3/​node_modules/​svelte-select/​Select.svelte:197:4) read reactive state that was not visible to the compiler. Updates to this state will not cause the statement to re-run. The behaviour of this code will change if you migrate it to runes mode

We are all waiting for svelte-select to upgrade but in the mean time I would like to not have all these warning in the console which also hide the warnings or real errors.

Reproduction

https://svelte.dev/playground/hello-world?version=5.5.2#H4sIAAAAAAAACm3LOwvCMBSG4b8SvqUK1e6xFNzcOxqHmp5CID0JyfFG6X-XesHF9eF9J3A3EjQO5H1Qt5B8r1bUO6F-jRKD85ShjxPkEZduAZTfax_jNl_Jy2LnLtM_t4GFWDI06myTi9IYNmLEjTEkUS15sqKGFEZVvK9NflmxM1xXv4frT1s1hlFC6C7Qki40n-Yna4ZePcsAAAA=

Severity

blocking an upgrade

@Leonidaz
Copy link
Contributor

Leonidaz commented Dec 4, 2024

I believe this should work:

// svelte.config.js

compileOptions: {
    warningFilter: (warning) =>
	!['reactive_declaration_non_reactive_property'].includes(warning.code)
}

Found an example usage in one of the tests:

docs are kind of skimpy at this point, definitely need more usage examples, but it's mentioned here: https://svelte.dev/docs/svelte/svelte-compiler#ModuleCompileOptions

@frederikhors
Copy link
Author

I think they should disable warnings for node_modules files by default.

@Leonidaz
Copy link
Contributor

Leonidaz commented Dec 4, 2024

just for posterity, here's an example for disabling node_modules warning:

from sveltejs/language-tools#650 (comment)

// svelte.config.js
export default {
  compileOptions: {
    // disable all warnings coming from node_modules and all accessibility warnings
    warningFilter: (warning) => !warning.filename?.includes('node_modules') && !warning.code.startsWith('a11y')
  }
}

@jamesbirtles
Copy link
Contributor

I'm not sure that warningFilter applies to runtime warnings?

@dummdidumm
Copy link
Member

The reproduction is not a minimum reproduction, but at least it's investigateable, code for the library lives here: https://github.com/rob-balfre/svelte-select/blob/master/src/lib/Select.svelte

It's not using runes so this is definitely a bug.

@dummdidumm dummdidumm added the bug label Dec 5, 2024
@frederikhors
Copy link
Author

frederikhors commented Dec 5, 2024

The reproduction is not a minimum reproduction

What can I do to help you?

@jamesbirtles
Copy link
Contributor

@dummdidumm
Copy link
Member

This happens because in some cases new signals are created while labeled statements are run, which itself is fine, but it messes with the detection logic. We would need to specify that certain signals (internal ones, and harmless new ones) are "fine", but I don't know how currently.

@brandonp-ais
Copy link

I'm not sure that warningFilter applies to runtime warnings?

It does not, at least in our app.

Not being able to filter out runtime warnings is making the console effectively useless for us at the moment.

@frederikhors
Copy link
Author

The suggested fix by @Leonidaz doesn't work unfortunately. After the 5.5.2 is unusable.

dummdidumm added a commit that referenced this issue Dec 10, 2024
…warning

fixes #14532

This removes the `reactive_declaration_non_reactive_property` warning altogether. The first version caused many false positives at compile time. The refined runtime version (introduced in #14192) was hoped to fix this, but it turns out we now get loads of false positives at runtime. The ones I've seen essentially revolve around a signal being created while reading or writing (to) something in a reactive statement, but in a matter which is harmless.

For example writing to `$$props` or `$$restProps` (like `$: { if ($$restProps.foo) $$restProps.bar = 'x' }`) creates a new signal under the hood, as the props now temporarily can get out of sync, and we need a backing signal for that. For this we call the `prop` function, which in turn creates several deriveds and may also read from user-land signals that were not read previously - in other words, it's not possible to fix the problem by marking all internal signals (which would be a very very tedious undertaking).

The potential benefits of this warning are vastly outnumbered by the false positives it causes, so we should just remove it.
@LeeNPham
Copy link

Anyone else have examples for how I can remove these overzealous warnings?

@knd775
Copy link

knd775 commented Dec 11, 2024

Anyone else have examples for how I can remove these overzealous warnings?

Just wait, they'll likely be gone this week #14663

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.

7 participants