mermaid
mermaid copied to clipboard
undefined is not an object (evaluating 'node2.id')
Description
Attempting to render the graph listed in Steps to reproduce causes an exception. I'm new to the project but managed to track down the exception to:
const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
...
const node2 = graph.node(v); // ‼️ node2 is undefined where v == "D"
...
log$1.info("Node - the non recursive path", v, node2.id, node2); // 💥 due to node2.id
Steps to reproduce
This graph renders fine:
graph TD;
subgraph A
subgraph B
C
end
end
A --> D
B --> D
C --> D
graph TD;
subgraph A
subgraph B
C
end
end
A --> D
B --> D
C --> D
But comment out the last edge and the render fails:
graph TD;
subgraph A
subgraph B
C
end
end
A --> D
B --> D
%% C --> D
Screenshots
No response
Code Sample
No response
Setup
Desktop
Mermaid: https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.5fa68f79.js
- OS and Version: macOS Ventura 13.1 (22C65)
- Browser and Version:
- Safari 16.2 (18614.3.7.1.5)
- Chrome 109.0.5414.119 (Official Build) (arm64)
Additional Context
No response
Thanks for identifying the bug @jjrscott! Do you want to give a shot at a fix too? We can help with the PR in case you run into issues. Looks like you've already identified the location.
I'm up for giving it a go, although there's a big different between tracking down a crash and fixing it. If you're able to point me in the right direction I'd be grateful.
I've further limited the issue to adjustClustersAndEdges
:
Hmm, so it fails if there are only links between subgraphs and nodes, instead of atleast one with another node.
I'm not sure, this graph also fails:
graph TD;
subgraph A
subgraph B
C
end
E
end
A --> D
B --> D
E --> D // ‼️Node to node
Closing this in favor of #4644, please refer to the new issue. It is a error that comes across different issues.