Skip to content

Storing component instances creates a circular reference loop in strict mode #1587

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

Closed
SergioCrisostomo opened this issue Jul 24, 2019 · 1 comment · Fixed by #1601
Closed

Comments

@SergioCrisostomo
Copy link
Contributor

SergioCrisostomo commented Jul 24, 2019

Version

3.1.1

Reproduction link

https://jsfiddle.net/Sergio_fiddle/zkrsa4g1/3/

Steps to reproduce

Store a pointer to a component instance in Vuex with strict: true.

What is expected?

No errors.

What is actually happening?

RangeError: Maximum call stack size exceeded

Vuex is adding watchers to all nested properties to warn if there are non-immutable changes inside a object (because of the strict mode help warnings) and does not stop when its entering itself.

In other words: when entering a component we can re-enter the store as a component property, and in the store we have a component that has a store etc etc ... we are in a loop


I think either:

  • Vuex should officially discourage from saving pointers of instances of Vue components in it

or

  • add a check to stop going deeper if the nested object it the Vuex instance itself
@Sequoya42
Copy link

Still got this issue in strict mode, loop until max stack exceeded.
Even used deepCopy (from vuex repo)
dispatch("setStuff", deepCopy(stuff));
=> fails in strict mode, works fine without strict enabled

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 a pull request may close this issue.

2 participants