question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Watch task in Gulp 4 gets slower every time it runs

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
robianmcdcommented, Jan 6, 2017

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

0reactions
esDotDevcommented, Jun 21, 2020

It is the recursive ** that causes this. gulp.watch('src/*.html', styles); should fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gulp tasks running slow - Stack Overflow
I'm getting poor performance from my gulp build. Node v0.10.29 Windows 8.1 x64. Gulpfile: // based off: https://github.com/kriasoft/SPA-Seed ...
Read more >
Gulp watch task is slow because it builds all CSS files - Drupal
Gulp watch task is slow because it builds all CSS files ; Reviewed & tested by the community ; Project: Zen ; Version:...
Read more >
Bad old Gulp getting extremely slow : r/Frontend - Reddit
Can't you run a watch gulp task that only compiles the elements you're working on instead of running your entire build every time...
Read more >
Gulp compile is this normal speed or unusually slow?
When you run gulp for the first time it's slow. Subsequent calls are a lot faster and gulp watch is faster yet.
Read more >
parallel() - gulp.js
Don't rely on this fix for very long. Avoid duplicating tasks#. When a composed operation is run, each task will be executed every...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found