chokidar: Gradually slower responsiveness to change events on Windows

I use it with gulp and have some time leaking. Looks like the problem in globs. Also on a bigger project, where I found this problem, for nested files creates nested.css-jds43J.TMP like files for a few miliseconds. Saw it in sublime sidebar

var gulp = require('gulp');
var chokidar = require('chokidar');

gulp.task('build', function () {
    return gulp.src('src/main.css')
        .pipe(gulp.dest('dist'));
});

gulp.task('dev', function () {
    chokidar.watch('src/**/*.css')
    .on('change', function () {
        gulp.start('build');
    })
})

File structure

src/main.css
src/include/nested.css

Log

[13:07:10] Starting 'dev'...
[13:07:10] Finished 'dev' after 4.38 ms
// A few changes in a row and periodical changes in main.css
[13:07:11] Starting 'build'...
[13:07:11] Finished 'build' after 54 ms
[13:07:11] Starting 'build'...
[13:07:11] Finished 'build' after 27 ms
[13:07:11] Starting 'build'...
[13:07:11] Finished 'build' after 19 ms
[13:07:12] Starting 'build'...
[13:07:12] Finished 'build' after 17 ms
[13:07:12] Starting 'build'...
[13:07:12] Finished 'build' after 23 ms
[13:07:14] Starting 'build'...
[13:07:14] Finished 'build' after 26 ms
[13:07:14] Starting 'build'...
[13:07:14] Finished 'build' after 10 ms
[13:07:14] Starting 'build'...
[13:07:14] Finished 'build' after 19 ms
// Periodical changes in nested.css
[13:07:17] Starting 'build'...
[13:07:18] Finished 'build' after 295 ms
[13:07:19] Starting 'build'...
[13:07:19] Finished 'build' after 321 ms
[13:07:20] Starting 'build'...
[13:07:20] Finished 'build' after 305 ms
[13:07:21] Starting 'build'...
[13:07:22] Finished 'build' after 341 ms
[13:07:24] Starting 'build'...
[13:07:24] Finished 'build' after 387 ms
[13:07:26] Starting 'build'...
[13:07:26] Finished 'build' after 336 ms
[13:07:29] Starting 'build'...
[13:07:29] Finished 'build' after 361 ms
[13:07:31] Starting 'build'...
[13:07:31] Finished 'build' after 397 ms
[13:07:34] Starting 'build'...
[13:07:34] Finished 'build' after 451 ms
[13:07:36] Starting 'build'...
[13:07:37] Finished 'build' after 368 ms
[13:07:38] Starting 'build'...
[13:07:38] Finished 'build' after 425 ms
[13:07:40] Starting 'build'...
[13:07:41] Finished 'build' after 464 ms
[13:07:43] Starting 'build'...
[13:07:43] Finished 'build' after 497 ms
[13:07:45] Starting 'build'...
[13:07:45] Finished 'build' after 429 ms
[13:07:47] Starting 'build'...
[13:07:47] Finished 'build' after 491 ms
[13:07:49] Starting 'build'...
[13:07:49] Finished 'build' after 540 ms
// A few changes in a row in nested.css
[13:07:52] Starting 'build'...
[13:07:55] Finished 'build' after 3.04 s
// Again periodical changes
[13:15:57] Starting 'build'...
[13:15:58] Finished 'build' after 669 ms
[13:15:59] Starting 'build'...
[13:16:00] Finished 'build' after 681 ms
[13:16:03] Starting 'build'...
[13:16:03] Finished 'build' after 725 ms
// Changes in main.css
[13:16:06] Starting 'build'...
[13:16:06] Finished 'build' after 23 ms
[13:16:07] Starting 'build'...
[13:16:07] Finished 'build' after 9.2 ms
[13:16:07] Starting 'build'...
[13:16:07] Finished 'build' after 17 ms

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 32 (1 by maintainers)

Most upvoted comments

@JustMaier, tried node 8.9.0 - same result for me. Guess we stuck with polling.

Update to Chokidar v3, it should resolve this.

I’m getting this same problem with Gulp 4 using the following gulp file.

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);
});

Running gulp watch outputs:

If I change the watch statement to use polling the issue doesn’t occur

gulp.watch('src/**/test.html', {usePolling: true}, styles);

Attached is a minimal app that reproduces the issue gulp-issue.zip

I am using the following versions node: v7.2.0 npm: 3.10.9 OS: Windows 10 Gulp CLI: 1.2.2 Local Gulp: 4.0.0-alpha.2