Grunt watch detects file changes only after 5 seconds with Vagrant and NFS

3.4k views Asked by At

Grunt watch (grunt-contrib-watch) is used to trigger reload of web app in browser. However, it is slow to notice file changes when running in a Vagrant virtual machine using NFS for synced folders. Changing a file triggers a reload only after about 5 seconds although it is expected to happen almost instantly. Why is grunt watch so slow to detect changes? Is there any way to make it faster?

With VirtualBox synced folders grunt watch detects file changes almost instantly. However, as VirtualBox synced folders are unacceptably slow for certain other operations on large amounts of files it is unfortunately not an option to revert back to it in this case.

1

There are 1 answers

3
Daniel Hawkins On BEST ANSWER

Try these mount options in your Vagrantfile:

type: "nfs", mount_options: ['actimeo=1']

This will greatly reduce the NFS file attribute caching timeout. I was having similar troubles, seeing large delays with Vagrant/NFS when waiting for gulp and Django server reloads. This fixed it; file changes are now detected instantly.