Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixes webpack/webpack#762 #40

Merged
merged 1 commit into from
Dec 21, 2016
Merged

Fixes webpack/webpack#762 #40

merged 1 commit into from
Dec 21, 2016

Conversation

roblg
Copy link
Contributor

@roblg roblg commented Dec 17, 2016

I believe this will fix webpack/webpack#762. I discovered that watch mode was firing an immediate rebuild because it thought files had changed that were changed immediately prior to watch running, but not during the watch build. I think after this change there's still the possibility that sometimes a second rebuild is fired immediately, but the time window for it should be much shorter.

Let me know if I'm missing something.

Cheers!

FS accuracy at startup is 10s, but it's fixed when files change. This
commit allows fs accuracy to be fixed at startup by examining file mtimes.
@jsf-clabot
Copy link

jsf-clabot commented Dec 17, 2016

CLA assistant check
All committers have signed the CLA.

@SpaceK33z
Copy link
Member

Since this is very tricky logic, a test would be really appreciated.

@roblg
Copy link
Contributor Author

roblg commented Dec 18, 2016

@SpaceK33z I'll try to pull something together. May not have time today, but should tomorrow.

It looks like there are already a handful of tests that fail on OSX, and I think it's the same issue reported in webpack/webpack#762. I'll see if I can clean those up as well.

Relatedly, I noticed while debugging that the FS_ACCURENCY variable on OSX ends up set to 2000 even though just by examining files on the filesystem, it looks like HFS+ has a 1s accuracy, which IIUC means that even with this PR, if you start watch less than 2s after creating or modifying a file, the watcher is going to report the file as changed, even though it hasn't. Before this PR, that number was 10s, the default value for FS_ACCURENCY. So I guess what I'm asking is: how far down this rabbit hole should I go? If y'all are willing to review, I can take a stab at a slightly larger cleanup (and trying to make the DirectoryWatcher class a little more easily testable), or I can keep it simple and we can all live with files being created <2s before the watcher starts immediately being reported as change.

@sokra sokra merged commit de3deda into webpack:master Dec 21, 2016
@sokra
Copy link
Member

sokra commented Dec 21, 2016

Thanks

sokra added a commit that referenced this pull request Feb 13, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node.js API watch callback calls twice during initial build
4 participants