Skip to content

Execution Graph to detect cyclic tasks #2287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

trulede
Copy link
Contributor

@trulede trulede commented Jun 8, 2025

Execution graph to detect cyclic tasks, replacing the TaskCalledTooManyTimesError mechanism.

Vertices in the graph are added for each unique call (to a task) and the PreventCycles feature of the graph is used to detect cyclic execution. The unique identifying properties are:

  • The task name, unique from the Taskfile AST/DAG mechanism.
  • The task hash, unique for an "instance" of a task call (e.g. set of vars).
  • Call "index" of the task, either from 'deps' or 'cmds'.
  • The sources method value, propagated as a call "token". This addresses a special case where a task call is cyclic, but the sources change between each cycle, and thus the task call should continue.

Although this method has worked remarkably well, it could be beneficial to have a mechanism to disable the detection: Environment variable (of course) and perhaps attached to an existing CLI parameter (--force).

fixes #820
fixes #2302

@trulede
Copy link
Contributor Author

trulede commented Jun 8, 2025

@korverdev Would you like to try this for you use case mentioned in comments of #820?

Clone the PR and then run task like this:
go run ./cmd/task -d <your directory> <your task>

@jberkenbilt
Copy link
Contributor

I can confirm that this PR also fixes #2302

@pd93 pd93 self-requested a review July 3, 2025 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

undetected dependency loop or deadlock with run: when_changed "probably an cyclic dep or infinite loop" on huge graphs
2 participants