question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Abort sequential chain on `task_error`

See original GitHub issue

For 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:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
throskamcommented, Mar 22, 2016

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.

0reactions
lukeedcommented, Mar 21, 2016

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.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found