Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] bug: StateProxy prevents modification of object array properties #1130

Closed

Conversation

TheAfroOfDoom
Copy link
Contributor

@TheAfroOfDoom TheAfroOfDoom commented May 12, 2024

context

this PR is purely to document a bug I noticed and went pretty deep to try and fix, but had did not resolve at time of writing

the high-level error was surfacing as this:

image

this was fixed in #1127 by removing that code path, but the root-cause of it may still cause issues in the future? tbd


StateProxy

StateProxy uses JS Proxy's to give us redo/undo operations on objects

from my understanding StateProxy.create(obj) basically returns obj with some extra methods on it

you can still modify obj's properties as you'd expect, for example:

const obj = {}
const proxy = StateProxy.create(obj)

proxy.x = 2
// obj.x === 2
// proxy.x === 2

the bug

if an object has a pre-existing array property, however, that property seems to silently fail to be modified?

const obj = { arr: [1] }
const proxy = StateProxy.create(obj)

proxy.arr = [2]
// proxy.arr is still `[1]` ???

proxy.arr[0] = 3
// `proxy.arr[0]` is still `1` ?????

i didn't test deeper if this was an issue specific to StateProxys (something custom to Spyglass) or JS's Proxy's generally, but am dropping investigation on this for now since #1127 fixes the original bug i was looking into anyway

@TheAfroOfDoom TheAfroOfDoom deleted the fix-expectation-checker branch May 12, 2024 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant