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:
const immutable = require("immutable");
let Foo = immutable.Record({foo: "bar"});
let fooInstance = Foo();
let Bar = immutable.Record(fooInstance);
let barInstance = Bar();
Tested in Firefox 64.0 with latest Immutable.js (4.0.0-rc.12).
From @joepie91 on Tue, 12 Feb 2019 12:51:29 GMT
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).
Copied from original issue: https://github.com/immutable-js/immutable-js/issues/1690