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

Watch task in Gulp 4 gets slower every time it runs #1878

Closed
robianmcd opened this issue Jan 3, 2017 · 9 comments

Comments

@robianmcd
Copy link

commented Jan 3, 2017

What were you expecting to happen?
If I run gulp watch with the following gulpfile and edit test.html by adding and removing whitespace, the "styles" task should take a similar amount of time every time the watcher fires

What actually happened?
Task takes longer every time it is run

task-time

Gulpfile

let gulp = require('gulp');
let rename = require('gulp-rename');

function styles() {
    return gulp.src('src/**/*.scss')
        //Issue happens with or without this rename plugin
        .pipe(rename({extname: '.test'}))
        //Issue only happens if destination directory is same as source directory
        .pipe(gulp.dest('src'));
}

gulp.task('watch', function() {
    //only happens if there is a glob here
    gulp.watch('src/**/test.html', styles);
});

What version of gulp are you using?
CLI version 1.2.2
Local version 4.0.0-alpha.2

What versions of npm and node are you using?
node: v7.2.0
npm: 3.10.9
OS: Windows 10

Zipped version of an app that reproduces the issue
gulp-issue.zip

@phated

This comment has been minimized.

Copy link
Member

commented Jan 3, 2017

Does this happen if you use chokidar directly? It'll be hard to test (you need to add stream completion timing around it) but it would help narrow this down. None of us have Windows to test this.

@robianmcd

This comment has been minimized.

Copy link
Author

commented Jan 4, 2017

Not sure how to test that but I'll try to find some time to learn more about it and test it out

@heikki

This comment has been minimized.

Copy link
Contributor

commented Jan 4, 2017

Similar (windows only) issue → paulmillr/chokidar#328

@ansballard

This comment has been minimized.

Copy link

commented Jan 6, 2017

Tried to reproduce on windows 10, gulp@4.0.0-alpha.2 using https://github.com/nolanlawson/marky for timing. Tried a list of absolute paths, then **/*.js. Build times fluctuated between ~300ms and ~450ms, but they didn't increase over 18 rebuilds. Sorry, I was hoping I'd be able to confirm the issue, let me know if you'd like anything else tested on a windows box.

@phated

This comment has been minimized.

Copy link
Member

commented Jan 6, 2017

@ansballard I don't think it can be achieved with that module. It's not a blocking operation. We have special logic that tracks completion of an async task (listening for the end of the returned stream).

@robianmcd

This comment has been minimized.

Copy link
Author

commented Jan 6, 2017

I tried adding {usePolling: true} to gulp.watch() and that "fixed" the issue. Not sure if that helps narrow it down.

@phated

This comment has been minimized.

Copy link
Member

commented Jan 6, 2017

@robianmcd based on that, I think this is an issue in chokidar (the issue already referenced). If you agree, please jump on that issue and close this one (since it's not something we control).

@ansballard

This comment has been minimized.

Copy link

commented Jan 6, 2017

@phated Sorry, didn't explain how I'm running the tasks. I'm calling the tasks via gulp.task("taskname")(args).then(result => ..., and the promise returned form the task is called from the finish event of the stream. But either way it doesn't reproduce the bug, so I'll keep my head down 😊

@robianmcd

This comment has been minimized.

Copy link
Author

commented Jan 6, 2017

@phated Yeah makes sense. I'll add my comments there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.