Open ghost opened 8 years ago
I think this is a problem in Chokidar and/or gulp-watch; it is missing some error handling at some point(s).
You see, once the watcher fires an event, we add a delay before reading the file contents. It is possible that the file no longer exists by then. It should be possible to reproduce the issue even without a delay, as external file system changes (e.g. deleting files) may happen at any time during script execution.
Not sure what's the best approach, maybe we can catch the error and don't fire the callback for added/changed files when they have been removed before we could read them.
By the way, I believe you can temporarily workaround the issue by ignoring the backup files, e.g.:
watch(['files/**/*', '!files/**/*~'])
Actually, I believe you should always ignore the backup files—you most likely don't want them to be processed by gulp. So, my comment above is the correct fix for your specific case, but we can keep this issue open to improve our error handling.
If anyone is interested in contributing with a patch, here's some useful info: https://github.com/floatdrop/gulp-watch/issues/242#issuecomment-230209702
Seems to occasionally crash on a temporary files created by the "Backup before saving" option in Atom. Getting the following error:
Disabling the option fixes the error for me but it's not ideal. Issue also opened on the Atom repo.