How to check if a circular dependency occurs due to a link in dhtmlxGantt?

I’m currently using dhtmlxGantt. Is it possible to detect in advance if a circular dependency might occur in certain situations

When I create a link from A to B, a circular dependency occurs, and it prevents the Gantt chart from functioning properly.

Is there a way to detect that this link would create a circular dependency before actually adding it?

Another problem is that I connect the preceding tasks in a separate window.

I know that onCircularLinkError event is thrown when linking from the UI, but what can I do when linking pre-work in a separate window?

Hello,
If you enable the auto-scheduling extension, you cannot create a link from a project task to its child task:

You can check how it works in the following snippet:
https://snippet.dhtmlx.com/qdl6be23

But if you create a link with the Gantt API (for example, with the addLink method), there are no limitations for that. So, you need to manually check if the link should be added.
Gantt calls the isLinkAllowed method before you finish creating a link from the UI. There are several conditions that Gantt checks to determine if it is a valid link:

  1. The source task’s id is equal to the target task’s id.

  2. If the type is set to a value that is not 0, 1, 2, or 3.

  3. If the link failed the validation.

  4. If the link is created from the project task to its sub-task. The dates of the project task depend on the dates of children tasks.

https://docs.dhtmlx.com/gantt/api__gantt_islinkallowed.html#:~:text=The%20cases%20when%20a%20link%20is%20considered%20as%20incorrect%3A

If you want to make a more complex check, you need to implement a custom solution by using the Gantt API and Javascript.