Webpack watch over nfs

For the past 3-4 weeks, webpack has failed to autoreload my watched webpack directories. It happened around the same time I enabled NFS, switching from SSHFS. I finally have a (potential) cause and a workaround! This can be a very annoying thing to deal with while trying to work on our front end.

So, apparently NFS doesn’t inotify clients of updated files, and webpack relies on inotify to know when to recompile code. There are a number of libraries [1] to forward inotify messages from one machine to another, but that seems like a Bad Idea to me (do let me know if there’s a supported way to do this).

An easy solution is to tell webpack to poll instead of rely solely on inotify:

WEBPACK_OPTS='--watch-poll 1000' ./script/foreman-start-dev

It’s not ideal, but it’s a quick workaround if you find yourself in this situation. I’ll be making a PR to foreman to add this to the readme.

1 Like

Thanks! For Katello, I added this to ~/foreman/.env's WEBPACK_OPTS which also has a bunch of other things by default for SSL. Webpack seems to reload for me fine now.

https://github.com/theforeman/foreman/pull/6007

1 Like

@akofink, yesterday’s problem is resolved related to webpack. I would like to share it to confirm that what I followed is appropriate or not. Below is the summary:

I will need to switch other alternative but currently I am using SSHFS for dev setup.

Suddenly, after I did rebase, faced similar issue that webpack has failed to compile and browser was loading old version of files.
After some troubleshooting, I realized that after rebase I ran npm install so in logs I found error lines:

UNMET PEER DEPENDENCY react@16.4.2
UNMET PEER DEPENDENCY  react-dom@16.4.2
UNMET PEER DEPENDENCY  webpack@3.12.0
  UNMET PEER DEPENDENCY  ajv@6.5.3

I did manual installation for first three. And now it works.
After this, I found there is PR-6012 opened by @amirfefer.

Would like to ask @amirfefer, is that ok if manually installed them or should I revert those packages and apply your patch changes to make it work?