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

fix(reactivity): infinite loops when pushing a variable to a custom proxy of reactive array #9750

Closed
wants to merge 8 commits into from

Conversation

zh-lx
Copy link
Contributor

@zh-lx zh-lx commented Dec 4, 2023

fix #9742

When user add a proxy to a reactive array and use motheds of Array such as push/pop/shift/unshift/includes/indexOf/lastIndexOf/splice, the result of toRaw(proxy) will always return proxy and infinitely trigger toRaw because receiver isn't the origin proxy(created by vue) of target.

So I think when we use the above methods, it should skip the comparsion between receiver and the origin proxy(created by vue) of target.

// Create a reactive array
const originalArray = reactive([]);

// Create a Proxy around the reactive array
const proxyArray = new Proxy(originalArray, {});

// Pushing elements to the Proxy array
proxyArray.push(1); // this will trigger toRaw infinitely

Copy link

github-actions bot commented Dec 4, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 86.8 kB (+82 B) 33 kB (+31 B) 29.8 kB (+16 B)
vue.global.prod.js 133 kB (+82 B) 49.9 kB (+42 B) 44.7 kB (+67 B)

Usages

Name Size Gzip Brotli
createApp 48.3 kB (+82 B) 19 kB (+27 B) 17.4 kB (+80 B)
createSSRApp 51.5 kB (+82 B) 20.3 kB (+30 B) 18.5 kB (+25 B)
defineCustomElement 50.7 kB (+82 B) 19.8 kB (+38 B) 18.1 kB (+40 B)
overall 61.7 kB (+82 B) 23.9 kB (+44 B) 21.7 kB (+64 B)

@yyx990803 yyx990803 closed this in 6ecbd5c Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working scope: reactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot .push() to a reactive Array that is wrapped in a Proxy
3 participants