You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mounted, before val++ 0 expected: 0
mounted, after val++ 1 expected: 1
destroyed, before val-- 1 expected: 1
destroyed, after val-- 1 expected: 0 <-- this is the problem
destroyed, before localVal-- 0 expected: 0
destroyed, after localVal-- -1 expected: -1
destroyed, after val-- (setTimeout) 1 expected: 0
This sounds similar to #14707 and #14911 in the sense that after a component unmounts the behavior of props and state becomes undefined or unpredictable.
It is kinda related but it's different...the problem is that when onDestroy runs the teardown of the stores has already happened. I wonder if we could simply delay the teardown to the next microtask to allow for onDestroy to run before. I'll have to investigate this and the consequences.
Describe the bug
onDestroy doesnt update global stores value (at the same onDestroy function).
Reproduction
open link: https://svelte.dev/playground/6acd83b2792743c6addd512ed492cdfb?version=5.16.6
press button 2 times to mount and destroy component.
check the logs.
Logs
mounted, before val++ 0 expected: 0 mounted, after val++ 1 expected: 1 destroyed, before val-- 1 expected: 1 destroyed, after val-- 1 expected: 0 <-- this is the problem destroyed, before localVal-- 0 expected: 0 destroyed, after localVal-- -1 expected: -1 destroyed, after val-- (setTimeout) 1 expected: 0
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: