-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: cleanup each
items in legacy mode
#16141
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
Conversation
Uh i guess i should fix also the other two cases |
🦋 Changeset detectedLatest commit: 18fec5c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Mmm this does make the example @7nik provided a looooot slower tho which is understandable since it's cleaning 1000 items everytime filtering the legacy array so maybe the benchmark did not capture this well enough? Not sure if we should go ahead and merge this like this...my other idea was to just skip falsy values in the legacy, sources, array and just set the spot to null but i would also need a way to get back the index somehow. |
Uhm actually the fix for await might be wrong as differently from the each the source is reused when the then branch is recreated? Will check maybe tomorrow, it's late and I'm too tired for this now, I might mess up something |
Mmm this technically does work in svelte 4 but it doesn't in svelte 5 (not that anyone should do this)...and by that I mean that reactivity is completely broken. <script>
import {beforeUpdate} from "svelte";
const promise = Promise.resolve({count: 0});
beforeUpdate(()=>{
console.log("before");
});
</script>
{#await promise then thing}
<button on:click={()=>thing.count++}>{thing.count}</button>
{/await} |
I opened alternative #16145 - looks like there is no need to track these signals at all. |
closing in favour of #16145 |
Closes #16040
Not really sure how to test this...i've also run the benchmark and it doesn't seem to be affected...also initially i've also removed the source from every reaction it had but i guess that's taken care by the
key
block/branch? This also lead me to believe that the memory leak is not really a memory leak and it would be cleaned up when the component it's unmounted but i guess for a situation like this one could still be good to clean the item immediately since it's not accessible in any way anymore.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint