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

Gulp4 watch only triggers once on Linux #2325

Closed
martinstuecklschwaiger opened this issue Apr 25, 2019 · 2 comments
Closed

Gulp4 watch only triggers once on Linux #2325

martinstuecklschwaiger opened this issue Apr 25, 2019 · 2 comments

Comments

@martinstuecklschwaiger
Copy link

What were you expecting to happen?

gulp.watch() should trigger on each file change.

What actually happened?

It only triggers for the first file change and then not anymore.
This happens on my Linux machine, but not with my colleague who uses Window.
Note: This is not because we forgot about the done callback.

> gulp singleFile 
[15:49:44] Using gulpfile ~/builder/workspace/walls.io/gulpfile.js
[15:49:44] Starting 'singleFile'...
... now I change file.js ...
[15:49:53] Starting 'runSingleFileWatcher'...
[15:49:53] Finished 'runSingleFileWatcher' after 838 μs
... I change file.js again, but nothing happens …
> gulp multipleFiles 
[15:50:51] Using gulpfile ~/builder/workspace/walls.io/gulpfile.js
[15:50:51] Starting 'multipleFiles'...
... now I change file.js ...
[15:50:55] Starting 'runMultipleFilesWatcher'...
[15:50:55] Finished 'runMultipleFilesWatcher' after 1.59 ms
... now I change file.js again ...
[15:50:57] Starting 'runMultipleFilesWatcher'...
[15:50:57] Finished 'runMultipleFilesWatcher' after 254 μs
... now I change file.js again ...
[15:50:59] Starting 'runMultipleFilesWatcher'...
[15:50:59] Finished 'runMultipleFilesWatcher' after 543 μs
... now I change file.js again ...
[15:51:01] Starting 'runMultipleFilesWatcher'...
[15:51:01] Finished 'runMultipleFilesWatcher' after 590 μs

Workarounds

  • Using a wildcard in the filepath (see exports.multipleFiles)
  • If I use {usePolling: true} it works
const gulp = require( 'gulp' );

// This will only trigger for the first file change
exports.singleFile = () => {
  gulp.watch("file.js", function runSingleFileWatcher(done) {
    done();
  });
};

// This works as expected
exports.multipleFiles = () => {
  gulp.watch("file.js*", function runMultipleFilesWatcher(done) {
    done();
  });
};

What version of gulp are you using?
CLI version: 2.2.0
Local version: 4.0.0

What versions of npm and node are you using?
Node: v8.11.4
Npm: 5.6.0
Running on Linux / Ubuntu 18.04.2 LTS

@phated
Copy link
Member

phated commented Apr 25, 2019

It's likely a chokidar issue but I don't think they care to work on the older version anymore. You'll probably have to use one of your workarounds 😭

@phated phated closed this as completed Apr 25, 2019
@specious
Copy link

I just discovered this issue (Arch Linux, F2FS file system).

Here's the discussion: paulmillr/chokidar#237

Using chokidar 3.x solves the problem.

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

3 participants