-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in LESS code causes silent failure? #171
Comments
+1, just noticed it. |
Related to #171 |
@stevelacy less is not consuming the errors, gulp-less is. Also related to #118 - they recommend checking output of lessc, as you can see, lessc correctly reports the errors: The only indication of a failure in gulp output is the fact that the task "Less" is started, but no corresponding line indicating it ever finishes shows up in the output. At that point, I have to then manually call lessc to see if there is any error causing it to not complete. Is there any way I can get the output from lessc to dump to console when running it through gulp?! I've tried the various workarounds mentioned in the issue tracker, registering "on error" callbacks - problem is there are various methods recommended, I'm not sure which syntax is the proper way & none appear to work. Any help? Furthermore, after fixing the syntax error in my less code, gulp does not attempt to start another "less" task, but the other watch tasks do run. I have to kill the gulp process where I'm running the watch, and manually restart it after fixing the syntax error in my code. Obviously not ideal. |
@joshribakoff gulp-less is a through stream. Any functions inside it modify the file, throw errors, etc. In this case less is actually modifying the error with it's JS API inside it's own promise scope. I manually took out the less render function and replaced it with a normal file parse. It worked correctly without consuming the errors. But anyway, not to argue on the semantics of the issue I will look into it when I have free time. |
I'm seeing this problem in gulp-less 3.3.0 (I just checked to make sure be18b01 is in my copy of index.js). Has there been a regression, or is there some other way to capture a parsing error? |
@mattsawyer77 Code? |
@contra My less task is essentially the following: gulp.task('less', function() {
var dest = uiRoot + '/css';
gulpUtil.log('compiling LESS...');
return gulp.src(sourcePaths.less)
.pipe(less({
sourceMap: true
}))
.pipe(gulp.dest(dest));
}); I can easily repro this by inserting some invalid characters into a .less file, which results in
but gulp abruptly stops executing at that point, and I get a 0 exit code. I tried instrumenting the stream with .on('error') and returning a promise which rejects if the stream errors, but the error handler was never called. If I remove the invalid characters, gulp works fine, and I can see that my less task finishes. |
should I file a new issue for this? Or do you think I'm potentially doing something wrong here? |
gulp.task('less', function() {
return gulp.src(sourcePaths.less)
.pipe(less({
sourceMap: true
}).on('error', console.log))
.pipe(gulp.dest(uiRoot + '/css'));
}); Does this log the error for you? Most people use something like gulp-plumber to wire up error management. |
@contra it does, thank you! |
+1 with @mattsawyer77 problem still exists in 3.3.2 I am confused if this problem should be fix in future release? The workaround #171 (comment) works gulp.task('less', cb => {
gulp.src(lessSourcePaths)
.pipe(less(...))
.on('error', cb)
.pipe(gulp.dest(cssDestRoot))
.on('end', cb);
} But it's still a very strange behavior that less consumes all errors and we even got a success exit code for gulp process |
we are now gulp 4.0.0 + gulp-less 4.0.0 problem still exists does not work: error printed out but task succeed gulp.task('less'), () => {
return gulp.src(lessSourcePaths)
.pipe(less(...))
.pipe(gulp.dest(cssDestRoot))
} not works neither: error totally lost gulp.task('less'), cb => {
return gulp.src(lessSourcePaths)
.pipe(less(...))
.on('error', cb)
.pipe(gulp.dest(cssDestRoot))
} not works neither: error totally lost gulp.task('less'), cb => {
gulp.src(lessSourcePaths)
.pipe(less(...))
.on('error', cb)
.pipe(gulp.dest(cssDestRoot))
.on('end', cb);
} finally this workaround works gulp.task('less'), cb => {
let succeed;
gulp.src(lessSourcePaths)
.on('end', () => { succeed = true })
.pipe(less(...))
.on('end', () => { succeed && cb() })
.pipe(gulp.dest(cssDestRoot))
} if you print a debug message in each if there's no error, both if error occurred, only the first |
Normally in the past the only issues I've had with this package is that it crashes the gulp watch on error. I have not changed anything recently, but I just noticed it fails silently instead of crashing now, when I give it invalid LESS inputs:
I start with an empty folder
I have a gulpfile which is roughly this:
contents of test.less:
back to console, I try to compile:
That's the full output. I do not get any further error messages (am not checking return codes). No other output occurs. I will list my
dist
dir again after runninggulp less
:If I fix the invalid syntax by prefixing it with "background-color:", it works as expected. I get an output of a "test.css" in my dir, and this gets printed to console:
Those are my actual results. My expected results would to see a LESS error message specifying the line number that is incorrect, printed to stderr of my console.
Thanks!
The text was updated successfully, but these errors were encountered: