sycamore icon indicating copy to clipboard operation
sycamore copied to clipboard

Disposing a signal after it is accessed but before it is tracked triggers a panic

Open lukechu10 opened this issue 1 year ago • 0 comments

Minimal reproducible example:

let _ = create_root(move || {
    let a = create_signal(());
    create_effect(move || {
        a.track(); // Track the signal as a dependency of the effect.
        a.dispose(); // Now dispose of the signal.
    }); // The effect is automatically run when it is created. However, it fails to add the signal to the dependency list since it no longer exists.
});

Resulting in this error:

panicked at /home/_/src/sycamore/packages/sycamore-reactive/src/root.rs:298:36:
invalid SlotMap key used

Expected behavior should just be to completely ignore signals that have been disposed before getting tracked.

Related to #739

lukechu10 avatar Oct 29 '24 23:10 lukechu10