we updated our project to use the latest GoJS release (v.2.3.11).
Now an error occurs when we try to set toNode on a link Node.
We do this after the diagramEvent LinkDrawn.
The link seems to be a valid Node and the Node we want to set on toNode is also a proper go.Node.
We did not change our code since we updated the GoJS version. When we go back to v.2.3.10, it works again without a problem.
The error in question:
After this line (link.toNode was null before) link.toNode = newNode;
TypeError: f is not a function
at T.set (go-module.js:1643:214)
I’ve updated the sample above to be more like yours and there are still no issues with 2.3.11.
Based on the error location, it seems like your Link.toPortChanged value is non-null. Could you put a breakpoint in your LinkDrawn function to verify whether link.toPortChanged is null?
I gave the go-debug-module.js a try and stepped through it.
When going down the setter of link.toNode you eventually come here through setToNodeForLink.
In t.wa, a is the data of the new node. The data object is correct. The function then proceeds to return the key inside the data object.
Can you keep stepping in to figure out when toPortChanged is being set from null to the key? Also, just to be sure, you aren’t using any minified property names, correct?
No we are not setting Link.to anywhere in our code.
We are also not using minified property names, only what is available in go.d.ts
I tried my best debugging this for an hour. There is a change being constructed on the data of the link that we set toNode on. But the change is about ‘to’.
.
.
I lost the trace here. My only guess left is that since something happens with promises/observables here, that something listens on changes and changes it retro-actively? link.toPortChanged is null until this function was executed/stepped through 2-3 times.
I deleted all packages and caches multiple times. Now I only get this error with the release go-module.js but not with the go-debug-module.js. If that helps.
@jhardy No, our application is not accessible publicly.
Edit: Outdated
The breakpoint in the setter of toPortChanged is a good idea, sadly it doesn’t yield any result.
The setter is not being called, only the getter.
Edit: Outdated
The custom build did not yield any different result. Same as before
The setter is still not called or at least the debugger wont stop there. Not even when I edit the build manually, adding a debugger statement in the setter.
Edit: Actually, I translated the changes (renaming to to zzz) into the ES6 bundle file which our application uses. Then it worked, the error was gone! I still cant debug it really, but I can now see that toPortChanged stays null
It does suggest that somewhere in your code accidentally you are setting a .to on a go.Link, and in your code before 2.3.11 this was just attaching a new property to that link since .to does not exist, but now its causing the problem.
You might want to search for .to (case sensitive, whole word) in all your code just to review each case, just in case. I know that your link data (very reasonably) contains .to, and maybe somewhere its getting set on a Link instead of Link data.
I did search our entire codebase for “.to” and also just “to” again.
And I found this in our connection template. Hidden in plain daylight:
new go.Binding('from', 'from').makeTwoWay(),
new go.Binding('to', 'to').makeTwoWay(),
Deleting the to binding solved the issue. I removed the “from” binding as well, since, as you guys stated, these are internal properties which are set automatically by the framework.
No more “f is not a function error” and the application works like before! 💯