Skip to content

Commit

Permalink
Fix false positive reporting of sync tasks on errors
Browse files Browse the repository at this point in the history
When a failure happens in a parallel task, it is totally normal that
other tasks have not reported completion, as gulp.parallel will report
the error without waiting for other tasks.
  • Loading branch information
stof committed Apr 16, 2020
1 parent d0cf312 commit 0e70ad0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/versioned/^4.0.0/log/sync-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ function clear(e) {
delete tasks[e.uid];
}

function clearAll() {
tasks = {};
}

function logSyncTask(gulpInst) {

process.once('exit', warn);
gulpInst.on('start', start);
gulpInst.on('stop', clear);
gulpInst.on('error', clear);
gulpInst.on('error', clearAll);
}

module.exports = logSyncTask;
13 changes: 13 additions & 0 deletions test/fixtures/gulpfiles/gulpfile-parallel-failure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

var gulp = require('gulp');

function noop(cb) {
cb();
}

function errorFunction(cb) {
cb(new Error('Error!'));
}

gulp.task('default', gulp.parallel(errorFunction, noop));
9 changes: 9 additions & 0 deletions test/non-completing-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ describe('sync-task', function() {
done();
});
});

it ('should not log false positive in case of parallel failure', function(done) {
runner({ verbose: false })
.gulp('--gulpfile ./test/fixtures/gulpfiles/gulpfile-parallel-failure.js')
.run(function(err, stdout) {
expect(stdout).toExclude('The following tasks did not complete: noop');
done();
});
});
});

0 comments on commit 0e70ad0

Please sign in to comment.