-
Notifications
You must be signed in to change notification settings - Fork 222
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
Debounced events seem to be getting lost #150
Comments
As far as I can tell, this looks pretty normal. But it would be better, I you could include the events you created. This way I have to guess what really happened. Keep in mind that FSEvents is very unreliable, you should probably use |
Ah, sorry, I don't have any events other than the ones in the log. What I did was create a file, move it out of the directory and move it back in. Upon moving it back in, it sometimes won't emit the debounced event. I don't really need the exact file, I just need to be notified every time something in the directory changes. You make a good point about the Notice events, I forgot about them, I will refactor my code to use that. Basically, I'm using the debouncer just for that, to avoid implementing my own (although I guess it's not that hard). Do you see any better way of implementing this so I am reliably notified? I plan to use the Notice events, like you said, but I worry that the method will still be unreliable sometimes. |
While there is no Notify API for it (yet, and for some time to come), on macOS if you want more immediate events you can try to use the kqueue kernel feature instead. It's a lot less easy to use, as you have to start watches on every file and directory you want events on, but as far as I know it's closer spiritually to Linux's inotify: hooked directly into the kernel calls, it theoretically emits right as things happen. |
Ah, thank you for the information. I don't need immediacy, I just need reliability. Hopefully |
Hmm, unfortunately this method doesn't work, as there is no |
Why do you need a |
The I am implementing the raw interface right now, but I'm having some problems figuring out what the events in This is the issue for the debounced interface. The 0-second watcher is seeing a
Since the two watchers are the same, I would expect this to happen instead:
How can the I don't know if I'm explaining this clearly, does the above help? |
The debouncer tries to remove duplicate events reported by FSEvents. But since your event log doesn't clearly show which watcher reports which event at what time, it's impossible to say whether there is an error in the debouncer or not. |
Here's the time stamped log:
As you can see, usually the immediate watcher gets events and five seconds later the delayed watcher gets them, except in the last one, where it never fires in the delayed watcher. |
Basically, I see two issues here:
|
Yep, the
results in a written file, but no |
I moved to a single, delayed watcher, and the |
Running an FSEvents sample, it catches the |
Ahhhh, this was dropped, I'm sorry to say. @dfaust What do you think about adding |
Yeah, totally forgot about this one, sorry. I added the NoticeWrite and NoticeRemove events because an application may have references to files that need to be invalidated immediately when the files change. This does not apply to newly created files. So I still don't know why NoticeCreate would be useful. |
Right. Let's close this cause it's been a year, and we can re-open if it's raised again. |
Note we might be hitting something similar in rust-analyzer in rust-lang/rust-analyzer#734. That is, on Mac(linux and windows work ok) the I don't have a mac so I can't debug this myself, and it very well could be a bug in our code though! |
Hmmm. I'll have my mac back next month, so I might be able to debug. I'll re-open out of caution anyway, given it seems there is something at least. Thanks for the second (tentative) repro! |
@passcod it was a false alarm after all, see rust-lang/rust-analyzer#734 (comment) The issue was that notify returned canonicalized paths, while the directory where the test was running was symlinked. We haven't canonicalized the dir name, and that made us to discard the canonicalized path as irrelevant, |
or maybe not... After we've fixed that issue, we hit another one in the same test, when, for |
I think I'm running into a similar thing on OSX with zola and with Pycharm only somehow.
when I edit a file. No Write whatsoever, just a weird chmod Editing the file in another editor (VSCode/Sublime/etc) works fine so that might be just Intellij doing weird/crazy things? |
Will look further but kneejerk is:
- intellij is known to do weird saves. This can be disabled iirc, or it
might be that this is another mode.
- chmod is actually "metadata", so that's probably the mtime change or
similar.
Any chance you can try with a raw mode notify to see the actual source
events?
…On Thu, 23 May 2019, 06:24 Vincent Prouillet, ***@***.***> wrote:
I *think* I'm running into a similar thing on OSX with zola
<https://github.com/getzola/zola/blob/master/src/cmd/serve.rs#L181-L204>
and with Pycharm only somehow.
I don't know if Pycharm/Intellij is doing something weird but when I edit
a file I get:
Event NoticeRemove("/Users/vincentprouillet/Code/zola/docs/sass/site.scss___jb_old___")
Event Chmod("/Users/vincentprouillet/Code/zola/docs/sass/site.scss")
Event Remove("/Users/vincentprouillet/Code/zola/docs/sass/site.scss___jb_old___")
when I edit a file. No Write whatsoever, just a weird chmod
Editing the file in another editor (VSCode/Sublime/etc) works fine so that
might be just Intellij doing weird/crazy things?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#150>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABGBC5XLFSR54K4VF45NHLPWWFWVANCNFSM4EPZLH6A>
.
|
For the reference, here's the code that is reponsible for "create temp file & do rename" dance: The config option for this is called "use "safe write"" |
Thanks, that's very helpful! So, @Keats, what you're seeing is either FSEvent only reporting, or the debouncing eating all but, the metadata event as triggered by this: if (myPreserveAttributes) {
FileSystemUtil.clonePermissions(oldFile.getPath(), myTargetFile.getPath());
} Now, in this particular case, you're getting an event. You may want to just add |
Thanks for the info! |
The raw events for writing in a markdown file:
|
Yeah, I think I'm starting to see how that happens, although I've just
written out and trashed three different theories and am still not happy
about it, so I clearly don't understand it enough yet (and I can't check
right now because my rust computer is on the fritz).
Nevertheless, that's super helpful, thanks. For now, adding chmod is your
best bet, and I'll work to find a fix for this (and other issues above)
right after the current release is done.
…On Sun, 26 May 2019, 03:30 Vincent Prouillet, ***@***.***> wrote:
The raw events for writing in a markdown file:
RawEvent { path: Some("/Users/vincentprouillet/Code/zola/docs/content/themes/_index.md___jb_tmp___"), op: Ok(CREATE | RENAME | WRITE), cookie: None }
RawEvent { path: Some("/Users/vincentprouillet/Code/zola/docs/content/themes/_index.md"), op: Ok(CHMOD | RENAME), cookie: None }
RawEvent { path: Some("/Users/vincentprouillet/Code/zola/docs/content/themes/_index.md___jb_old___"), op: Ok(REMOVE | RENAME), cookie: None }
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#150>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABGBC657VFSB3KX4WBC3H3PXFLRHANCNFSM4EPZLH6A>
.
|
I'm new to rust, so this may be my fault, but I can't see why.
I create two debounced watchers here:
https://gitlab.com/stavros/hearth/blob/master/src/main.rs#L149
I do this so I can be notified immediately so I can emit a "change detected" event and then, after changes have stopped and 5 seconds have passed from debouncing, I process the files and emit a "done" event.
However, sometimes this "done" event seems to get lost. The code is identical, it's two debounced watchers, one with 0 seconds and one with 5 seconds delay, running in different threads. However, the 5 second watcher doesn't seem to fire, sometimes.
Here's a log of the printed events:
Log lines before "Change detected in filesystem" are events coming in to the 0-second debouncer, and log lines before "Adding files to IPFS" are events coming in to the 5-second debouncer.
As you can see in the last line, an event came in that never got to the 5-second debouncer. The log line is right after the event is received, so I have no code between the reception of the event and the processing of it.
The text was updated successfully, but these errors were encountered: