Skip to content
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

Stops piping after error when gulp-watch is used #86

Closed
demisx opened this issue Sep 23, 2014 · 8 comments
Closed

Stops piping after error when gulp-watch is used #86

demisx opened this issue Sep 23, 2014 · 8 comments

Comments

@demisx
Copy link

demisx commented Sep 23, 2014

I have a strange issue, that gulp-sass()stops piping files after a SASS error when used with gulp-watch (v0.7.1).

  1. When SASS files are error free, I see 'Writing sass' message each time I update a *.scss file.
  2. Then I deliberately introduce an error into one of the SASS files. I see an error message from gulp-plumber as I should.
  3. However, when I undo this error, I no longer see "Writing sass" message and no CSS files are being written to the .build/ directory. I need to restart gulp watch-sass to make things go back to normal.

Please note, that this doesn't happen if I use the gulp.watch method instead (see code snippets below).

This is where the problem described above takes place:

# In gulpfile.coffee
sass = require("gulp-sass")
... ... ...
gulp.task "watch-sass", ->
  watch
    glob: filePath.appDir + "/**/*.scss"
  .pipe plumber()
  .pipe sass()
  .pipe using prefix: "Writing sass" 
  .pipe gulp.dest('.build/')
  return  

However, no such problem using gulp.watch:

# In gulpfile.coffee
sass = require("gulp-sass")
... ... ...
gulp.task "watch-sass", -> 
  gulp.watch filePath.appDir + "/**/*.scss", (file) ->
    gulp.src file.path
    .pipe plumber()
    .pipe sass()
    .pipe using prefix: "Writing sass" 
    .pipe gulp.dest('.build/')
    return
@floatdrop
Copy link
Owner

Why don't you switch onto 1.0.x? Possible cause - you using streaming mode in gulp-watch, but callback in gulp.watch. Can try to use callback in gulp-watch to?

@demisx
Copy link
Author

demisx commented Sep 24, 2014

I've tried to switching to 1.0.x a couple of weeks ago, but ran into many issue that I didn't have time to work on those at the time. I'll try to upgrad again.

As far as this issue go, switching to callback fixed the issue:

gulp.task "watch-sass", ->
  watch filePath.appDir + "/**/*.scss", (files) ->
    files.pipe plumber()
    .pipe sass()
    .pipe using prefix: "Writing sass" 
    .pipe gulp.dest('.build/')

Shouldn't this work in the pipe mode as well?

@demisx
Copy link
Author

demisx commented Sep 24, 2014

Filed this issue in dlmanning/gulp-sass#90 as well, since the poblem goes away when I replace gulp-sass with gulp-less.

@kaii-zen
Copy link

kaii-zen commented Oct 2, 2014

I have exactly the same issue and I'm compiling snockets (through2 and using snockets module directly) so I don't think it has anything to do with gulp-sass

@kaii-zen
Copy link

kaii-zen commented Oct 2, 2014

This also happens when not using gulp-watch.
If I introduce an error on purpose then no matter if I use gulp-watch or not and no matter if I use plumber or just .on('error', gutil.log), the stream will stop when it encounters an error.

@kaii-zen
Copy link

kaii-zen commented Oct 2, 2014

Sorry my bad. It does work with plumber() (it doesn't work with just catching the error though). The problem in my case was that I was using a sync function in a through2 stream and didn't bother to try..catch 😑

@alexander-akait
Copy link

I have some issue with pipe

watch(directory.src, {
            name: 'Watcher "Copy"',
            verbose: true
        }, function (files, cb) {
            gulp.start('copy', cb);
        }).pipe(plugins.fncallback(function (file, enc, cb) {
            console.log('fire');
            if (file.event === 'deleted') {
                console.log('deleted');
                if (plugins.cached.caches && plugins.cached.caches['copy-files'] && plugins.cached.caches['copy-files'][file.path]) {
                    console.log('Forget ' + file.path);
                    delete plugins.cached.caches['copy-files'][file.path];
                    plugins.remember.forget('copy-files', file.path);
                }
            }
            cb();
        }));

pipe not fire after next run

@floatdrop
Copy link
Owner

I guess this is not problem with gulp-watch (from @demisx comment). Feel free to reopen if it is not.

@sheo13666 try to update on 4.0.0 - if this still a problem, file new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants