Prefer watchFile over watch #18

Merged
merged 1 commit into from Jul 5, 2012

Conversation

Projects
None yet
4 participants

A commit log should not only explain what it changes but also why... why is watchFile > watch?

(EDIT: I wager it's because fs.watch() doesn't work with NFS mounts but that's speculation on my side.)

Contributor

mattpardee commented Jul 4, 2012

@bnoordhuis The issue was the frequency at which watch events were dispatched, and the vagueness of the events dispatched. This forced the callee to do a stat on the file anyway and find out what changed.

It also may have been the cause for some very, very odd behavior. We would be watching a file "/path/to/file.md" and after the first time the contents of the file were modified and an event was dispatched (oddly enough with the event type "rename") it would subsequently emit "rename" events on the parent directory every time there was a change and at seemingly random intervals.

We were baffled by this mystery but I had used watchFile with success before. It worked here without any of the aforementioned issues.

I realize the consistency of watchFile is greater because it stats on a regular interval but the consequences of using this technique are low. Even on c9.io this is not an issue because each workspace is in its own container.

Contributor

creationix commented Jul 5, 2012

I'm fine with this change. Who else is using this API? Isn't @cadorn using it for something?

Contributor

gjtorikian commented Jul 5, 2012

@creationix Yes: https://github.com/c9/c9local/issues/220

That's where this whole issue started from. File watching appeared broken on Cloud9 Local, but was actually broken on Cloud9 OSS. The change here works for both repos.

creationix merged commit 2be2154 into master Jul 5, 2012

Contributor

creationix commented Jul 5, 2012

Published to npm as vfs-local@0.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment