TypeError: Cannot read property 'start_date' of undefined

Sometimes I click on a task and this error appears

Uncaught TypeError: Cannot read property ‘start_date’ of undefined
at l.getItemPosition (dhtmlxgantt.js:10)
at n (dhtmlxgantt.js:10)
at Object.get_endpoint (dhtmlxgantt.js:10)
at Object. (dhtmlxgantt.js:10)
at Object. (dhtmlxgantt.js:10)
at Object.render_item (dhtmlxgantt.js:10)
at Object.restore (dhtmlxgantt.js:10)
at Object._redrawItems (dhtmlxgantt_smart_rendering.js:10)
at Object.t._smart_render._redrawItems (dhtmlxgantt_keyboard_navigation.js:10)
at Object.updateRender (dhtmlxgantt_smart_rendering.js:10)
at Object. (dhtmlxgantt_smart_rendering.js:10)
at Object.i (dhtmlxgantt.js:10)
at Object.t.callEvent (dhtmlxgantt.js:10)
at Object.scrollTo (dhtmlxgantt.js:10)
at Object.showDate (dhtmlxgantt.js:10)
at Object. (dhtmlxgantt.js:10)

Hi @douglas !

I’ve tried to reproduce this error, but I don’t quite sure how and when it happens.
It seems to be related to the rendering of links. The stack trace shows that the error fires when gantt tries to display a link that is connected to a task that is not loaded into gantt.
I can trigger the very same error it if I stop the code execution during smart rendering repaint and insert some random value into source or target property of the link object that is going to be displayed: https://www.screencast.com/t/iNpsE3Ry
But the error doesn’t happen if I provide gantt with such links initially: http://snippet.dhtmlx.com/41e8504a3 - here I generate sample dataset and generated links with random values of source/target properties. Everything seems working correctly in this case.

Thus, I’m not sure how the error happens and can’t file a bug until I have a way to reproduce the bug.

Maybe it is associated with smart rendering extension and link rendering. The error pops up if in the source and the target attributes of the links are the id values of nonexistent tasks.

Please check the source and the target values of the links.

If you think that this is not the cause of the problem, please share a snippet of your code in this link and send it to me:
http://snippet.dhtmlx.com/41e8504a3

This error occurs when you use order_branch and DataProcessor
https://snippet.dhtmlx.com/d08f6e29e

Change the order and click on the task, see the console . After this error, the project does not work, the data is no longer sent to the server.

Hi @douglas!

It appears to be a bug on our end, thank you for reporting it. I’ve submitted it to our internal tracker, and the dev team will fix it and it will be published with one of the next bugfix releases.

After dragging the task, its data object gets the target property. Gantt defines a task object as a link object in its calculations, which also has a target property. This is the cause of the issue.

As a workaround for the issue, please remove target key from the task using setTimeout() in onRowDragEnd event listener:

gantt.attachEvent("onRowDragEnd", function(id, target) {
  setTimeout(function(){ 
    var task = gantt.getTask(id)
    delete task.target; 
    gantt.updateTask(id);
  }, );

});

Here is your snippet with a workaround:
http://snippet.dhtmlx.com/38f0b3080

1 Like

Hello Douglas,
The bug was fixed in the 6.1.7 version:
https://docs.dhtmlx.com/gantt/whatsnew.html#617
You can test that it is no longer reproduced in the following snippet:
https://snippet.dhtmlx.com/7d7ffe9dd

1 Like