Skip to content
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

Does fsevents_monitor can capture all file updates ? #265

Open
bric3 opened this issue Jan 11, 2021 · 3 comments
Open

Does fsevents_monitor can capture all file updates ? #265

bric3 opened this issue Jan 11, 2021 · 3 comments

Comments

@bric3
Copy link

bric3 commented Jan 11, 2021

Hi,

Thanks for this utility, this issue is more a question about fs events on macos than to report a problem, so when watching a file directly, I noticed that fs monitor don't report events on a log file, I'm using JetBrains IntelliJ IDEA log files as an example.

$ fswatch -x --monitor=fsevents_monitor /Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log
^C%
$ fswatch -x --monitor=kqueue_monitor /Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated PlatformSpecific
^C%

It seems that only kqueue_monitor is picking the events on this log file.

However when I use some command lines to modify the file (additionnally to IntelliJ IDEA), then fsevents_monitor picks up some events, altthough they are not the same as those reported by kqueue_monitor :

$ fswatch -x --monitor=fsevents_monitor /Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log PlatformSpecific IsFile <=== touch idea.log
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated IsFile <=== echo "line" > idea.log

Also, I tried to use fswatch to watch events on the parent directory:

$ fswatch -xr --monitor=fsevents_monitor /Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log PlatformSpecific IsFile <=== touch idea.log
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated IsFile <=== echo "line" > idea.log

FS events monitor picks events the same events when touching or appending via a command line tool (touch or echo "" >> ), but not from the process (IntelliJ IDEA) that is really appending log messages.

If using kqueue monitor for this folder, nothing gets captured unless I use the -r option, not even when the file modified with a command line tool (touch or echo "" >> ).

$ fswatch -xr --monitor=kqueue_monitor /Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log PlatformSpecific
/Users/bric3/Library/Logs/JetBrains/IntelliJIdea2020.3/idea.log Updated

The documentation (1.14.0) suggests that fsevents is to be preferred on OSX, but is it really the prefered way if monitoring specific files. Or am I missing something ?

Thanks in advance for the feedback !

bric3 added a commit to bric3/drain-java that referenced this issue Jan 12, 2021
This is the last batch, because native-platform uses macOs's fsevents
to handle file events, which does not pickup all file changes.
While `tail` is based on BSD's kqueue, and report correctly file
changes.

This finding has been confirmed with the tool fswatch (it implements
various way to watch files ; on macos: fsevents, kqueue, or polling).

Reference issues :
* gradle/native-platform#269
* emcrisostomo/fswatch#265
@emcrisostomo
Copy link
Owner

Hi @bric3, I don't know, I'll try to reproduce it and investigate it

@bric3
Copy link
Author

bric3 commented Jul 9, 2021

@emcrisostomo Hi, did you had the chance to investigate ?

@alvis
Copy link

alvis commented Aug 16, 2023

I notice the same issue when I try to monitor node_modules folders created by pnpm using fsevent monitor.
Seems like when the number of file changes is small, it's working fine.
But whenever there's a large number of file changes, some are missing RANDOMLY.

The probabilistic nature of the issue may suggest it's some kind of buffer or queue size overflow?

@emcrisostomo is there any queue size parameter we can tweak?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants