Cannot set property 'order' of undefined
See original GitHub issueGreetings. I am seeing the following error:
TypeError: Cannot set property 'order' of undefined
at dagre.core.js:1395
at arrayEach (lodash.js:1289)
at Function.<anonymous> (lodash.js:3345)
at dagre.core.js:1394
at arrayEach (lodash.js:1289)
at Function.<anonymous> (lodash.js:3345)
at assignOrder (dagre.core.js:1393)
at order (dagre.core.js:1371)
at dagre.core.js:495
at notime (dagre.core.js:2897)
After doing some debugging I see the following:
function assignOrder(g, layering) {
_.each(layering, function(layer) {
_.each(layer, function(v, i) {
g.node(v).order = i;
});
});
}
In this function layer
is an array, seemingly containing strings (maybe id’s). When this error crops up, it seems that several items in the layer
array are undefined
. Therefore g.node(undefined)
also returns undefined and produces the error.
I am currently going through our code to see what might be causing the issue, but was hoping that maybe the authors had some insight into what I might look for.
Issue Analytics
- State:
- Created 6 years ago
- Comments:38
Top Results From Across the Web
JavaScript - cannot set property of undefined - Stack Overflow
I get the following error: Uncaught TypeError: Cannot set property 'greeting' of undefined. I'm trying to do something similar to an associative ...
Read more >How to solve the 'cannot set property of undefined' issue on ...
To access an object key the object has to exist. When it doesn't and you try to access the key, you get the...
Read more >TypeError: Cannot set properties of Undefined in JavaScript
The "Cannot set properties of undefined" error occurs when setting a property on an undefined value. To solve the error, conditionally check if...
Read more >Uncaught TypeError: Cannot set property
In JavaScript if a variable has been declared, but has not been assigned a value, is automatically assigned the value undefined . Therefore,...
Read more >Cannot Read Property of Undefined in JavaScript - Rollbar
What Causes TypeError: Cannot Read Property of Undefined ... Undefined means that a variable has been declared but has not been assigned a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mmacfadden thanks to your reproducer and some guesswork i think i found out the problem.
Let me explain, the problems seems to be related to the way
lodash
forEach
works, the methodutil.buildLayerMatrix
builds a matrix, but the orders assigned there (layering[rank][node.order] = v;
) are not always consecutive, so it ends up with a matrix with “holes” between orders.forEach
methods seems to iterate over theseundefined
values in theassignOrder
and thus the reported exception.See a reproducer of what i mean:
This yields:
@Revadike, it’s likely because this project has no maintainer, as announced in the README.