Alignment node throws the memory Maximum call stack size exceeded

Hi Walter,

I have the functionality to align the selected node along the x or y-axis.
I am utilizing diagram.selected.toArray() to obtain a list of the selected nodes and set their x and y positions. After that, I am setting the state property and then rendering the diagram.It is calling the diagramModelChnaged event and throw the below exception.


it is thrown by DataSyncService.syncNodeData service.
I am not introducing any cyclic dependencies. I am only updating the location property of the state object.

Could you show us your code that is updating state?

It must be an immutable state update, which is where immer is helpful.

I am using the deep clone to update the state object

I am using the code below to resolve my immer issue, but the location data is updating.

I would think you’d only want to call produce once with all the updated node data state. Are you saying there’s no error now but the diagram isn’t updating? Does your node template include a location binding?

Yes, my node includes the binding for that location.

I am setting the state, which fires the diagramModelChange event and updates the state, but the diagram does not refresh. If I save the diagram and then re-render it, the changes will be visible.

Is there any issue with the GoJs level that is preventing transaction committed, or am I missing something?

Here’s a working example: gojs-angular-align-x - StackBlitz

I’m not sure what may be causing the issues in your app. See the alignX method.

Thanks for the code. If I change skipDiagramUpdate to false, it continuously calls the diagramModelChanged event.

You’ll need to debug that. Something in your code is causing unnecessary updates.

I got that I set the flag Thanks…
but the issue is still not resolved.

The sample I provided works, so you’ll need to figure out how your setup is different.

We cannot debug your code for you. You have a working example to reference now.

“I appreciate your help. I will review and inform you if I have any further concerns.”

Thanks for your effort in resolving the issue. The demo was very helpful.