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

some mutation methods of Array cause infinite recursion #2137

Closed
unbyte opened this issue Sep 17, 2020 · 6 comments · Fixed by #2138
Closed

some mutation methods of Array cause infinite recursion #2137

unbyte opened this issue Sep 17, 2020 · 6 comments · Fixed by #2138

Comments

@unbyte
Copy link
Contributor

unbyte commented Sep 17, 2020

Version

3.0.0-rc.12

Reproduction link

https://codepen.io/unbyte/pen/ExKePMY

Steps to reproduce

  1. open the terminal

What is expected?

effects should only run one time, cuz no reactive dep has changed

What is actually happening?

infinite recursive update


I've fixed it by #2135 , however it was closed by some misunderstanding.

I've created another PR #2138 to fix it.

This recursion is not due to the self-calls of the effect, but that push changes .length while it depends on .length (however this dependency is not really needed)

@unbyte unbyte changed the title Array.prototype.push causes infinite recursion Array.prototype.push/pop/shift/unshift causes infinite recursion Sep 17, 2020
@unbyte unbyte changed the title Array.prototype.push/pop/shift/unshift causes infinite recursion Array.prototype.push/pop/shift/unshift cause infinite recursion Sep 17, 2020
@dsonet
Copy link
Contributor

dsonet commented Sep 17, 2020

What about method splice?

@CyberAP
Copy link
Contributor

CyberAP commented Sep 17, 2020

This is expected since your effect is mutating its dependency.

@unbyte
Copy link
Contributor Author

unbyte commented Sep 17, 2020

@CyberAP I don't think it's reasonable, operating one array in two effects leads to infinite recursive call, it sounds crazy 😂

@unbyte unbyte changed the title Array.prototype.push/pop/shift/unshift cause infinite recursion some mutation methods of Array cause infinite recursion Sep 17, 2020
@CyberAP
Copy link
Contributor

CyberAP commented Sep 17, 2020

You'll get the same result in Vue 2, the problem here is with the logic of the code, not with the Vue's API.

@unbyte
Copy link
Contributor Author

unbyte commented Sep 18, 2020

@CyberAP any repro in Vue 2? 😲

yyx990803 added a commit that referenced this issue Sep 18, 2020
@hyf0
Copy link
Contributor

hyf0 commented May 21, 2021

I don't consider it as a bug or something need to fix. That's how it should be. It looks similar to #3653.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants