Sometimes diagram.model.removeLinkData(linkdata) not working


I been having this problem since last night, I want to delete some links from the diaram programmtically. Here’s the code.

let linksToRemove = [];
node.findLinksInto().each(function(link) {
node.findLinksOutOf().each(function(link) {

	console.log(diagram.model.containsLinkData(; // return false  !!!! This should be true. some times return true though 
	console.log(diagram.model.containsLinkData(; // return false

This result in sometime the links are deleted while sometime is not. I dont know what could be the issue?


I suggest using a go.Set and Diagram.removeParts instead.

diagram.startTransaction('removing links');
diagram.removeParts(new go.Set().addAll(node.linksConnected));
diagram.commitTransaction('removing links');

The problem with your original code, @Kakit, is that you were calling GraphLinksModel.removeLinkData on the Link instead of on the Only the data is in the model, not the Link (or Node) object.

In addition, Simon has improved the code to be clearer and simpler.

Hi walter,

I noticed that, it was my typo when I posted on this forum, in my code it is