-
Notifications
You must be signed in to change notification settings - Fork 2k
coffee --watch stops detecting changes to files #1853
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
Comments
Sigh. Sorry about this. Here's the story so far:
Could you show me your test code? The current master should only stop watching a file if a |
There isn't any specific code that causes this issue, it is simply caused by discarding uncommitted changes in a git repo that CS is watching. I put together this video to show what I'm seeing: http://vimeo.com/31979347 In this video I'm using the latest revisions of CoffeeScript and NodeJS as of this morning: I'm not seeing the assertion anymore, but watch still dies when the changes are discarded. |
Thanks for the detailed report. I'll try to replicate and figure this out ASAP. In the meantime, you might want to work off a fork that uses fs.watchFile (see my reopened pull request). On Nov 11, 2011, at 11:00 PM, David [email protected] wrote:
|
Cool, let me know if I can provide any more assistance. This isn't a show stopping issue for me, watch works way better in the latest revision then in the 1.1.3 release. This is the only issue I've run into in 1.1.4-pre and it only happens in this rare case of uncommitting changes. |
This is going to be hard to fix... the problem is that The only way to solve this without polling is to watch the parent directory of each watched file as well. |
If you watch the parent directory would it be possible to detect new CS files to compile? This is something I always wished watch did. |
@InScopeApps: See @TrevorBurnham's comment over at #1847 saying we could do exactly that. Whether we want to do that is the question. |
I think it's fairly obvious that we do. The feature has been requested multiple times, and Jeremy's objection has always been "Your laptop battery life will be the better off for it." That objection no longer applies if we're scanning the directory anyway (and only when its contents change). In fact, the implementation that recognizes all new files is more elegant and efficient than the one that just fixes this issue. Not recognizing new files would require us to ask on each directory event, "Did this file exist during our first sweep?" |
I was making a reference to #1846, putting off the adoption of this new API until it's actually stable. But yeah, if we want to write all that code for our "simple" compilation tool, I wouldn't mind reviewing the pull request. |
@TrevorBurnham I just tried your branch and it looks like it does fix this issue! It doesn't seem to compile new CS files though, is this behavior not being added? |
@InScopeApps Detecting new files in directories with |
Makes sense, too bad about |
It used to work fine pre CS 1.1.3 |
Try installing the latest master. There's an issue where some programs "save" files by moving a temporarily file on top of the existing one, rather than writing to the existing file directly, so that may be what you're seeing. On the current master, coffee tries to work around this. On Nov 27, 2011, at 9:06 PM, Tim [email protected] wrote:
|
@TrevorBurnham: Thanks for the tip. I'm running 1.1.4-pre (current master) now. Unfortunately this doesn't change anything. Compiling works fine, compiling with |
Ahh found something interesting! The problem I described only occurs in Dropbox folders. So I guess this is basically an issue with node.js Funny that this behavior didn't exist back when |
Hmm, it turns out to be even more complicated. But I think this is an issue with node.js so will report at nodejs/node-v0.x-archive#1986. |
Looks like watching for file changes is rather tricky business. Wouldn't it be an idea to go for a more dumbed down and therefore simpler approach instead? Compass's command line utility offers a |
Yes, just doing fs.stat every 500ms might well be the simplest solution. In principle, though, fs.watch is more efficient (polling is impractical for large numbers of files) and will allow us to detect the creation of new files in watched directories. On Nov 27, 2011, at 10:35 PM, Tim [email protected] wrote:
|
@TrevorBurnham: Note that the way (Thanks for the suggestions for Jitter and WatchIt. Those look like potential solutions. But clearly it's far from an ideal situation having to resort to such far-fetched measures just to get a tiny part of a tool chain to work properly.) |
@timmolendijk To be clear, I agree that we should be using |
As do I. |
Looks like Jeremy is reconsidering |
Trevor and Michael, please take a look at the above patch... I've (hopefully) fixed the issue by waiting to re-watch the file after a rename for a quarter second. This behaves fairly well on MacVim, on my machine -- although I am able to get it to crash with an |
Still experiencing the same behavior:
When the process gets stuck after using TextMate 2 using TextEdit after that won't help - probably again caused by whatever TM2 does to the file after the initial change is done. |
How about TextMate 1? That's the same version of OSX / Node / Coffee that I'm using... |
Just tried installing TM1, node, CS on a machine I don't use for dev work - wanted to be sure that it isn't something local. Tried it with TM1 and it works fine - changes are detected every time the file is updated. The latest revision of TM2 allows the two versions to co-exist so tried it with TM2 and same results as on my dev machine - only the first time the change is detected and any subsequent change is not. Whatever TM2 is doing is messing things up. Let me know if you need me to try something else and thank you for checking this out. |
BTW Using Trevor's jitter which I think uses fs.watchFile() works fine - does what I need until this is resolved. |
So, what's going on is pretty alarming: Somehow, the way TM2 saves files causes a |
@zonak Try the current master. |
Yep ... works great. Thank you for your attention on this. |
Is this issue showing up on HFS+ drives? Textmate 2 uses exchangedata() for atomic saving — this should preserve the inode, but if on a third party network w/o atomic swap then it creates a new file. You can check if you inode is the same by doing – Michael, Macromates |
Yep, the file system is Journaled HFS+. Trevor's latest changes do resolve the issue and thank you for looking into this. |
Thanks for the info, Michael. I'll pass it on to the Node team, and hopefully they'll be able to fix the fs.watch implementation. On Dec 23, 2011, at 4:07 AM, Michael [email protected] wrote:
|
Don’t know if this is related, but some “watch’ algorithms look for increases in the file’s last modified property. When you do a git revert, the last modified property is reverted as well, and the watch algorithm won’t catch the revert because the last modified has decreased instead of increased. The correct implementation seems to be to watch for a changing fingerprint or for any change to the last modified property. Apologies if this is wrong and/or irrelevant to this specific issue... |
Nice catch. We should definitely fix it to be |
Aren't we doing that already?
|
Oops -- nevermind then. |
@TrevorBurnham Thanks, my bad for not reviewing the source before commenting! |
@raganwald No prob; it's good to know for the future. |
While using the head revision of CoffeeScript and a build of NodeJS from yesterday I encountered a failure while running
compile --watch
.This happened after I discarded changes on a CS file in a git repo. I tested that this was reproducible.
This appeared to be bubbling up from NodeJS so I rebuilt from the head revision. There were some commits about
uv
andfs.watch
so I hoped this would fix the problem. Unfortunately it only hid the issue, I re-ran my test and didn't see the assertion but watch stopped working.The text was updated successfully, but these errors were encountered: