task icon indicating copy to clipboard operation
task copied to clipboard

feat: add failfast support for parallel tasks

Open elvism-lullabot opened this issue 8 months ago • 4 comments

Implement new failfast behavior to terminate the parent task immediately when any child task fails.

This replaces the previous default behavior, where he execution will stop as soon as any task fails.

New default behavior

By default, when running tasks, the execution of child tasks continues even if one fails.

Restoring Previous Behavior

To restore the previous behavior, you can explicitly set failfast: true or with the flag --failfast.

Example

With this configuration, if task-a fails early, the parent will stop immediately without waiting for task-b or task-c.

version: '3'

tasks:
  task-a:
    cmds: [ "bash -c 'echo A; sleep 1; exit 1'" ]
  task-b:
    cmds: [ "bash -c 'echo B; sleep 2; exit 0'" ]
  task-c:
    cmds: [ "bash -c 'echo C; sleep 3; exit 1'" ]

  parent:
    deps: [task-a, task-b, task-c]
    failfast: true  # To restore the previous behavior

elvism-lullabot avatar Jun 24 '25 22:06 elvism-lullabot

Looking forward to seeing how tests go here!

@elvism-lullabot is this defining "fail fast" backwards? To me, failfast: true matches the current behaviour of task. If we set it to false, it would mean we'd "fail slow" and let existing tasks run to completion.

deviantintegral avatar Jun 27 '25 16:06 deviantintegral

Looking forward to seeing how tests go here!

@elvism-lullabot is this defining "fail fast" backwards? To me, failfast: true matches the current behaviour of task. If we set it to false, it would mean we'd "fail slow" and let existing tasks run to completion.

I updated the code so that the failfast behavior matches the PR description and desired logic.

elvism-lullabot avatar Jul 08 '25 17:07 elvism-lullabot

Really excited for this. I'm not a maintainer, but I wonder if it would make sense to make failFast default to true, to preserve the existing behaviour, so this could be shipped quicker (wouldn't be a breaking change)?

anthony-hayes avatar Jul 14 '25 13:07 anthony-hayes

I have tested these changes and they seem to work as described. Excited for this one to be merged!

rabbitlair avatar Aug 05 '25 18:08 rabbitlair