Skip to content

leak between createStore and createMutable of object references and proxy objects #1396

@LiQuidProQuo

Description

@LiQuidProQuo

Describe the bug

createStore and createMutable proxy handlers are exclusively bound to an object reference.

let raw = {count:5}
let [s, setS] = createStore(raw)
let m = createMutable(raw)

both s and m share the same raw object, however, since createStore was called 1st
the raw object is associated to the immutable proxy.
and m is also immutable, as it returns the same proxy initially associated by createStore.

why?
because in solid the reactive proxies are singletons, looked up by the object reference

if we reverse the order

let raw = {count:5}
let m = createMutable(raw)
let [s, setS] = createStore(raw)

s is now a mutable proxy.

can this be fixed?
probably (not easily or without some more overhead) but at least should be documented, that createStore and createMutable should not use the same objects.
as it may break expectations when working with one or the other.

Your Example Website or App

https://playground.solidjs.com/anonymous/7e274c6d-5d46-4af4-9552-1eecd17333ea

Steps to Reproduce the Bug or Issue

see

Expected behavior

above

Screenshots or Videos

No response

Platform

play

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions