svelte: Strange cleanup bug when using {#each} block
Describe the bug
I don’t know if this relates directly to the use of createSubscriber or not. I have a class that uses this function. The class takes some options that can only be set during construction, so the consumer of the class uses a $derived to construct a new instance every time the desired options change.
The store contains an array. I don’t know if other types of data trigger this issue, or not, but array is what I have at work, so the reproduction uses an array.
Just by using an {#each} block to iterate the contents of the store is enough to make the previous store instance to fail cleanup.
Not shown in the repro, but if you manually access each item in the array as opposed of using the {#each} block, the problem doesn’t happen and the previous store instance cleans up just fine.
Reproduction
Logs
No response
System Info
REPL
Severity
blocking an upgrade
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (16 by maintainers)
Ofc. I’ll dig into this
@paoloricciuti could you post your repl?
I tried with an effect and also just wrapping the variable holding the instance in a signal and inside
onclicksetting it to a new instance but same thing.