Skip to content

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

@lukechu10

Description

@lukechu10

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-reactivityArea: reactivity and state handlingC-bugCategory: bug, something isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions