Abort sequential chain on `task_error`
See original GitHub issueFor instance:
export async function foo () {
console.log('Perform foo');
}
export async function bar () {
console.log('Perform bar');
}
export async function error () {
throw 'Something went wrong!';
}
export default async function () {
await this.start(['foo', 'error', 'bar']);
}
The tasks bar
is performed even if the previous task has failed.
The expected result can be achieved with the following:
export default async function () {
this.on('task_error', function () { process.exit(1); });
await this.start(['foo', 'error', 'bar']);
}
but I feel it should be the default behavior especially for tasks like linting or testing which should abort subsequent compilation or packaging tasks.
The error is dismissed in the fly exec
function:
*exec (task, value, inject = this) {
_("run %o", task)
try {
const start = new Date()
this.emit("task_start", { task })
value = (yield this.host[task].call(inject, value)) || value
this.emit("task_complete", {
task, duration: (new Date()).getTime() - start
})
} catch (error) { this.emit("task_error", { task, error }) }
return value
}
Either the error should be thrown or the fly start
function should handle the task_error
event.
I’m trying out fly and I didn’t see any error handling example or convention on the matter so maybe I’m missing something ? How should I properly abort a tasks chain ?
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Ignore errors when running npm scripts sequentially
That error stops the sequential execution of the script. Is there a way to ignore errors and keep executing down the chain?
Read more >mostly-adequate-guide-it/ch9.md at master · MostlyAdequate/mostly ...
Because chain effortlessly nests effects, we can capture both sequence and ... Since chain is mapping under the hood, if any value is...
Read more >Taming the async beast using Tasks | by Yannick S | Medium
Let's chain all the things ! function handleError(err) { /* do something with the error */ }function getJSON(url) { return new Promise((resolve, ...
Read more >Asynchronous Programming - GNOME Developer Center
The class should provide some kind of 'close' or 'cancel' method which can be used by other ... Chain up. ... Cancelling it...
Read more >schrodinger.tasks.tasks module — Schrödinger Python API ...
Execute each function in the specified chain sequentially in order. ... failing preprocessor will raise a TaskFailure exception and terminate processing.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree, parallel tasks are creating new tasks chains that shouldn’t be impacted by any errors in other chains.
Typically it would be for use cases such as
linting
,compiling
,packaging
. It makes no sense to package if the compilation or linting process has failed.I’d only agree as far as sequential tasks (
parallel: false
) are concerned, but even then, no process should be exited.Parallel tasks are independent of one another – that is the point, after all.