task icon indicating copy to clipboard operation
task copied to clipboard

Execution Graph to detect cyclic tasks

Open trulede opened this issue 7 months ago • 3 comments

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 https://github.com/go-task/task/issues/820 fixes #2302

trulede avatar Jun 08 '25 14:06 trulede

@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>

trulede avatar Jun 08 '25 18:06 trulede

I can confirm that this PR also fixes #2302

jberkenbilt avatar Jun 28 '25 21:06 jberkenbilt