-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Files created right before watching starts make watching go into a loop #25
Comments
The watching may loop in a unlucky case, but this should not result in a different compilation hash. I. e. the webpack-dev-server doesn't trigger a update if the hash is equal. |
Ah, but Im experiencing this issue 100% of the time, because I am
|
Would be nice to resolve this without having to fork webpack or delay
|
@sokra " When chokidar is using fswatch (OSX), Maybe It'd also be nice if it got renamed to |
We are having the same problem. A workaround we found is to manually change the mtime of the file before it gets picked up by Webpack, but it feels like just adding a hack on top of a hack. |
This problem has been haunting our team for a while. Files are being stored on doInitialScan() 10 seconds in the future and this generates multiple webpack-dev-middleware builds until the future becomes the past. It seems to me that watchpack should compare mtimes between nextTick()s instead of trying to guess if the mtime is in the future or in the past. |
Watchpacks strategy is: if not sure if it's a change, thread it as change. With low fs accuracy files could have changed even if mime is equal. Normally multiple rebuilds shouldn't cause issues and this cause should be cached by the caller by comparing hash. I.e. the webpack CLI doesn't display stats output for equal hash. Nevertheless this may could be fixed in watch pack by storing the time of the initial scan/watcher installation and useing this time. |
How is FS_ACCURENCY helping in that case? If the filesystem doesn't provide the precision necessary to detect the change, FS_ACCURENCY will only add X milliseconds to that lack of precision. If mtime didn't change because of lack of precision, adding FS_ACCURENCY to it won't make it any different. The only reason I can imagine is when trying to guess if the mtime is in the future or not, and what I propose is to stop doing that and just act upon the change in mtime itself. |
FYI, here's an extract of what we see if we have a recent change before starting webpack-dev-middleware. I put a loop printing the current date in the background and added some console.logs for debugging purposes showing
|
We are experiencing the endless rebuilding problem even for files that weren't created shortly before watching started. This is a problem that has affected us with Webpack 1 as well as 2, and occurs sporadically but often enough that it makes working with webpack-dev-server a chore and it almost makes one long for the days of grunt-watch and BrowserSync. ;) Here is a link to our config: This is on Windows 7 Enterprise x64 with Node 6.9.1, and seems to primarily happen when IntelliJ IDEA is open. I should also note that we have seen the problem when using |
For anyone else tearing out hair over this, backdating the relevant files by ten seconds is an awful hack but it worked for me: var f = path.resolve('someFile')
var now = Date.now() / 1000
var then = now - 10
fs.utimes(f, then, then, function (err) { if (err) throw err }) Update - This fix stopped working for me at some point, but Yassky's solution further down the page works great. |
You just made my day @AndyHall I confirm that his solution works like a charm! |
Same here, check #53. My explanation why this happens is very detailed. |
Webpack also has this bug if the files are created early in the process but AFTER calling Strangely enough, doing a command line |
Working solution for me: Compare with last stored hash.
|
@aseem2625 I think with your solution, we would have 2 compiles instead of a loop. (Second build->hash is extra) |
@pi0 |
Still quite looking forward to this problem has a solution as soon as possible |
Looking forward to the master to fix this problem, contribute a pr to webpack/watchpack |
Hope that there can be a solution |
I am looking forward to the official solution to this problem. |
old issue problem is kind of expected behavior we reduced the startup filesystem accuracy to 1 second which should reduce the problem |
Given the number of people complaining, "expected behavior" seems inappropriate as a classification. Why not just get rid of FS_ACCURACY? |
I still have this issue and this cannot be the expected behavior... |
I'm having this issue too and the suggested workarounds don't work. Can you reopen this? |
Same issue here. The only fix for me was to add the plugin: https://github.com/yessky/webpack-mild-compile |
i'm experiencing this bug, but with webpack 5. i've try using webpack-mild-compile but no hope. any idea how to resolve this issue? |
|
having this issue right now, the solutions don't seem to work (that is if I'm doing them correctly) |
Having the same issue with webpack 5 |
Popping in here to say that I have a similar problem because I need to manipulate a file Webpack is watching before the watch compile occurs. The only solution that has worked for me is to combine the solution proposed by @fenomas with the information I found in webpack/webpack#7997 by @jods4. By changing the Edit for context:
|
Hi. Lost a workday because of this. Please, consider fixing it. Thanks. |
Its again happening in Angular 16 related. Kindly fix this permanently. thank you. |
I've noticed this strange behaviour where watcher loops for 10 seconds due to this code:
watchpack/lib/DirectoryWatcher.js
Lines 202 to 205 in 7efdd93
What I'm doing in my script is basically creating a file in a temporary directory
/temp/entry.js
, creating a webpack compiler and runcompiler.watch()
. Now for 10 seconds (which is the default value of FS_ACCURENCY) this is what's happening:/temp/entry.js
file, because it's < 10 seconds oldAny pointers on how to fix this would be helpful. For example, this could be fixed by modifying the above code to this, but I'd need to stare at this for longer to understand what this block of code is conceptually responsible for.
The text was updated successfully, but these errors were encountered: