-
Notifications
You must be signed in to change notification settings - Fork 56
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
multiple parents and node invariant check #103
Comments
Hi @fundkis Thanks for your thoughts, you have described the most usual problem when working with freezer.js, using a node that has been detached from the store. I completely agree that it is a problem very difficult to debug, and I have learnt to use freezer in a way that minimize the chances of getting an incoherent state like the one you describe, but I can imagine that many people suffering this issue. I will be glad to study and merge your solution. As for the singleParent checking, and the need of not having the nodes frozen, I think I didn't understand it well, can you explain it further? The immutability of the nodes are a nice feature to make sure that the tree is updated the right way, but it's possible to disable it using Also letting a node be in 2 different places in the tree is a feature, but I am not against creating an option to enforce the opposite if it's not making the library much more complex and can help to detect errors. Thanks again for your thoughts they are really valuable :) |
thank your for the answer. |
Now I see, you meant that with the 'singleParent' option set to |
of course. we should be backward compatible... |
Hi,
First, we want to thank you for this library. We loved it and we loved the way it simplify react interaction...
We found recently an issue in our code that makes the freezer nodes point to multiple parents (old node pointers) that makes the whole freezer tree incoherent: children pointing to parents not on the freezer tree.
The issue is our fault, but it was very hard to detect. It could have been much easier if freezer integrate some check code that can be enabled in debug...
First, we wrote an invariant function that verifies the whole tree. This is how we figured out that there was a bug.
When debugging we realized that freezer allows multiple parents for a single node. We don't use this feature and we consider it bad usage in general to have such a tree.
If we disable such a feature, we can enforce that any subtree that need to be plugged in a feezer tree should not be frozen (should not contain the __ field). We implemented this precondition check and this is what help us to identify our guilty code.
To sum up, freezer should provide :
If you agree with the above and you are ready to integrate our contribution, we will be happy to provide a Pull Request.
Otherwise, we think about a lighter implementation that will be compatible with a subset of freezer-js...
The text was updated successfully, but these errors were encountered: