lake icon indicating copy to clipboard operation
lake copied to clipboard

Add a way to stop `lake build` on first failure

Open Julian opened this issue 2 years ago • 5 comments

Perhaps related to #34, it also might be helpful if there was a -x / --fail-fast option for lake build which stopped immediately on the first error (or first file with error).

Julian avatar Feb 06 '22 00:02 Julian

Unfortunately, due to currently heavily parallel nature of Lake builds, this is not very feasible at the moment. There is currently no way, within Lake itself, to know what the failure is "first". And even if that was discoverable, there is also no way to cancel the other running build tasks in order to quit early. However, I will keep this feature request in mind should future refactors make this possible.

tydeu avatar Feb 06 '22 16:02 tydeu

Thanks for considering it! For context, I'd see value personally even if this was strictly something that controls output, even if it didn't cancel builds at all (at least initially) -- when doing some refactor I can't cope with lots of output, I want to see just one thing to fix, and have it be quick to see, and then repeat that process as fast as possible. But yeah thanks for considering it regardless!

Julian avatar Feb 06 '22 16:02 Julian

In parallel build systems, there are various degrees to which this problem is solved - Nix outright kills running tasks if one fails by default, while Make at least does not start any new tasks (perhaps because, unlike Nix, it has to worry about inconsistent build directory state resulting from the abort). If I'm not mistaken, the latter at least should be implementable simply with a global IO.Ref Bool that is checked whenever a build Task is run.If that's not already the case?

Kha avatar Feb 06 '22 16:02 Kha

A wrinkle in @Kha's solution is that Lake starts all tasks immediately linking them together (via Task.bind) based on dependencies. So there are no tasks are spawned regardless after the build has started. Conceivably, the task could check some global state after waiting for dependencies and before the start of the next build. However, since tasks are arbitrary functions, this would have to be a manual check within each written task.

tydeu avatar Jun 22 '22 17:06 tydeu

Yes, that's what I meant by "whenever a build Task is run" (not "queued"). There could be a wrapper around the Task functions that automatically checks and propagates a CancelToken. Perhaps that should even be integrated into Task itself.

Kha avatar Jun 23 '22 09:06 Kha