Gulp 4: gulp.parallel will stop gulp immediately when one task fails
Created by: per2plex
In the docs it is stated that gulp.parallel will still execute all tasks if an error occurs:
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.
This currently doesn't seem to be the case as the following minimal code example will demonstrate:
var gulp = require('gulp')
gulp._settle = false
gulp.task('error', function(done) {
setTimeout(function() {
done(new Error('Somethings wrong!'))
}, 200)
})
gulp.task('willnotfinish', function(done) {
setTimeout(function() {
console.log('I will never finish :(')
done()
}, 2000)
})
gulp.task('watch', function() {
gulp.watch('watchme.js', gulp.parallel('default'))
})
gulp.task('default', gulp.parallel(
'error',
'willnotfinish'
))
This will stop running gulp after ~200ms with the following output and the task 'willnotfinish' will never finish executing:
Using gulpfile ~/Desktop/development/gulp-parallel-error/gulpfile.js
Starting 'default'...
Starting 'error'...
Starting 'willnotfinish'...
'error' errored after 204 ms
Error: Somethings wrong!
at null._onTimeout (/Users/perplex/Desktop/development/gulp-parallel-error/gulpfile.js:5:10)
at Timer.listOnTimeout (timers.js:92:15)
'default' errored after 211 ms
The following tasks did not complete: willnotfinish
Did you forget to signal async completion?
EDIT: Include watch task in code sample