gulp-livereload icon indicating copy to clipboard operation
gulp-livereload copied to clipboard

Race condition

Open tomek-he-him opened this issue 10 years ago • 4 comments

Hi, and thanks for this great piece of code!

Our task needs to clean the files before building new ones. Here’s a summary of our output.

[19:45:52] Starting 'demo:clean'...
[19:45:52] Finished 'demo:clean' after 172 ms
...
[19:45:53] Starting 'demo'...
[19:45:53] .../demo/dashboard.html reloaded.
[19:45:53] Finished 'demo' after 5.54 ms

The problem is that when Chrome reloads the window, it doesn’t manage to find the files. Perhaps the filesystem IO takes too long? BTW, my task looks like this:

gulp.src(settings.source)
  // do stuff
  .pipe(gulp.dest(settings.targetPath))
  .pipe(livereload())
  .once("end", function () {done();})
  ;

How about an option debounce? It would also prevent triggering 10 reloads one after another when 10 files are changed one after another. So this:

livereload.listen(
  { debounce: 200
  });

would trigger a reload 200 ms after the last change in a series of file changes.

Here’s a nice interactive explanation of debouncing: http://reactivex.io/documentation/operators/debounce.html

tomek-he-him avatar Apr 10 '15 18:04 tomek-he-him

+1 on this!

bradvogel avatar May 18 '15 03:05 bradvogel

Hey, @tomekwi! Just wanted to let you know that I've created a standalone fork of this repo, since it doesn't seem to be maintained anymore. You can find it here.

So I might be a good idea to re-open this issue there.

leo avatar Feb 17 '16 13:02 leo

Hi @leo, thanks for tackling this! I don’t really use gulp anymore – I’m doing my best to keep my builds so simple that an npm script does the job. But thumbs up and the best of luck to you!

tomek-he-him avatar Feb 19 '16 07:02 tomek-he-him

@tomekwi Ahh, alright! :blush:

leo avatar Feb 19 '16 09:02 leo