-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Describe the bug
NOTE: the code in the provided repl does reproduce the bug, however, it seems to be environment specific and does not surface in the repl itself. Please see the reproduction section.
Assuming your environment is in a reproducible state...
There are two logically identical constructor functions that create a reference to an object. The only difference is one is written in the .svelte file and another is imported from a .svelte.js file. The imported version has different behavior. It fails to retrigger the console.log() in the imported effect when you press the "update obj import" button (which mutates the enclosed state that the effect is dependent on). I've isolated the cause to line 8 in test.svelte.js: val = {}. If you comment this out, then the bug goes away in all setups that I've experimented with thus far.
It appears as though reassigning to a state rune variable in an imported effect disables reactivity on the state rune variable.
Reproduction
Reproduction is finicky. I have NOT been to replicate this in the repl (I suspect it get's masked by hot-reloading).
Code: https://svelte.dev/playground/f0d8a97ba7844192b21591288a8dbf0d?version=5.25.8
My local reproduction has been with:
"svelte": "^5.25.8",
"@sveltejs/kit": "^2.20.4",
With a local vite server, the bug does NOT show up first time the page is loaded (after kicking off the server). But it does on subsequent page refreshes. You can replicate this cycle by right clicking the refresh button in Chrome (with the dev panel opened) and clicking "empty cache and hard reload." Then, it will not show up again, except on subsequent refreshes.
With a deployed version of the app (not publicly available), the opposite is true. It is only reproducible on first load, but is NOT reproducible on subsequent refreshes. Again, you can reset the cycle and make it reproducible again by "empty cache and hard reload."
If there more information that I can provide to help reproduce this, please let me know. Thanks!
Logs
System Info
System:
OS: Linux 4.18 CentOS Stream 8
CPU: (32) x64 Intel(R) Core(TM) i9-14900K
Memory: 38.49 GB / 62.33 GB
Container: Yes
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 18.16.0 - /usr/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 9.5.1 - /usr/bin/npm
pnpm: 10.7.1 - /usr/bin/pnpm
Browsers:
Chrome: 134.0.6998.35
npmPackages:
svelte: ^5.25.8 => 5.25.8Severity
annoyance