-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
"too much recursion" error when creating a Record type from an instance of another Record #1690
Comments
I think I know what you tried to achieve. Maybe there should be an error or something, but I think this is more clear.
Or, if you really want the Bar default value to be what fooInstance has.
Which in this case would be a value "bar" for |
Nah, I didn't actually intend to have two separate Record types and have one contain the other; I just erroneously tried to wrap an object in The problem is that it didn't produce an understandable error, and therefore it took a long time to figure out that the problem was an erroneous double call of |
What happened
When creating a new Record type, and passing in an instance of another Record as the schema / default values, Immutable will end up in an infinite recursion loop, yielding the following error:
I don't know whether it conceptually makes sense to try to do this (see the repro below); in my case the 'nested Record' structure was caused by a mistake during refactoring.
However, the current error is completely unclear about the cause of the issue, and provides no real way to track down the cause. I ended up spending several hours trying to find the root cause.
Expected behaviour: Either produce an understandable error with concrete guidance (if this is not supposed to be supported), or work correctly without breaking (if it is supposed to be supported).
How to reproduce
Repro:
Tested in Firefox 64.0 with latest Immutable.js (4.0.0-rc.12).
The text was updated successfully, but these errors were encountered: