Shape of links inconsistent

We are using treelayout but at times Link between nodes get flaky and do not draw a direct link. You have to move around the nodes to get it to correct itself
Any ideas why is it happening and solutions ?

Error :-

Ideal behaviour , which only occurs after we move some nodes:-

I can’t explain that without more information about the graph, the layout, the nodes, and the links.
Are you setting Link.routing = go.Link.AvoidsNodes? Since you are using TreeLayout I suggest you just use routing == go.Link.Orthogonal.