Skip to content

Gulp complains that a task did not finish when a parallel task fails #2168

@MLoughry

Description

@MLoughry

What were you expecting to happen?

In gulp 4, when using gulp.parallel, I expect that all tasks to complete, even if one task fails. The API documentation is ambiguous:

When the returned function is executed, the tasks or functions will be executed in parallel, all being executed at the same time. If an error occurs, all execution will complete.

I'm not sure if that means "all tasks will finish execution", or "all execution will be cut short".

Either way, if the latter is the intended behavior, gulp should not complain that a task did not signal async completion.

What actually happened?

The non-erroring task did not complete, and gulp complained that the non-erroring task did not signal async completion

PS D:\vso\gulp-parallel> gulp a
[16:37:06] Using gulpfile D:\vso\gulp-parallel\gulpfile.js
[16:37:06] Starting 'a'...
Starting work in task "a"
Finished work in task "a"
[16:37:07] Finished 'a' after 1 s

PS D:\vso\gulp-parallel> gulp ab
[16:37:10] Using gulpfile D:\vso\gulp-parallel\gulpfile.js
[16:37:10] Starting 'ab'...
[16:37:10] Starting 'a'...
[16:37:10] Starting 'b'...
Starting work in task "a"
[16:37:10] 'b' errored after 1.6 ms
[16:37:10] Error: Task "b" failed!
    at formatError (C:\Users\miclo\AppData\Local\Yarn\config\global\node_modules\gulp-cli\lib\versioned\^4.0.0\format-error.js:20:10)
    at Gulp.<anonymous> (C:\Users\miclo\AppData\Local\Yarn\config\global\node_modules\gulp-cli\lib\versioned\^4.0.0\log\events.js:31:15)
    at Gulp.emit (events.js:132:15)
    at Gulp.emit (domain.js:421:20)
    at Object.error (D:\vso\gulp-parallel\node_modules\undertaker\lib\helpers\createExtensions.js:61:10)
    at handler (D:\vso\gulp-parallel\node_modules\now-and-later\lib\map.js:46:14)
    at f (D:\vso\gulp-parallel\node_modules\once\once.js:25:25)
    at f (D:\vso\gulp-parallel\node_modules\once\once.js:25:25)
    at tryCatch (D:\vso\gulp-parallel\node_modules\async-done\index.js:24:15)
    at done (D:\vso\gulp-parallel\node_modules\async-done\index.js:40:12)
[16:37:10] 'ab' errored after 5.64 ms
[16:37:10] The following tasks did not complete: a
[16:37:10] Did you forget to signal async completion?

Please post a sample of your gulpfile (preferably reduced to just the bit that's not working)

const gulp = require('gulp');

gulp.task('a', done => {
    console.log('Starting work in task "a"');
    setTimeout(() => {
        console.log('Finished work in task "a"');
        done();
    }, 1000);
});

gulp.task('b', done => {
    done('Task "b" failed!');
});

gulp.task('ab', gulp.parallel('a', 'b'));

What version of gulp are you using?
4.0.0

What versions of npm and node are you using?

PS D:\vso\gulp-parallel> npm --version
5.6.0
PS D:\vso\gulp-parallel> node --version
v9.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions