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

fix: filter file watcher duplicate events #200

Conversation

Valentin271
Copy link
Contributor

@Valentin271 Valentin271 commented Dec 20, 2023

This fixes #198

As discussed in the issue, I refactored the file watcher to use notify_debouncer_full.

I did so with as few modifications as possible to avoid breaking anything. The most interesting part is the DebounceEventHandler impl in which I basically filtered unwanted and duplicate events.
The debouncer timeout of 10ms seems good for up to 100 ~ 150Kb files on my machine.

All unit tests passed locally. I've also tested with the files I was having issues with.

I also added logs I found interesting for debugging and changed the log format to show milliseconds since the file_watcher is always faster than a second.

@CosmicHorrorDev
Copy link
Collaborator

CosmicHorrorDev commented Dec 20, 2023

Seems to be failing on mac, but all the file watching logic is notorious for platform specific quirks. I'll go ahead and re-run the failed jobs, but I doubt they'll pass this time (more so for my sanity). I won't be able to take too close of a look till after holidays, but I'll still be around to hit the CI button or for reviews (I also think CI l still runs in your fork when you push to it for whenever I'm not around)

@Valentin271
Copy link
Contributor Author

Alright no problem. I had a feeling it would only work on my machine, it's good you have a CI to check that. I'll fix them.

It does run on my fork after enabling it.

@CosmicHorrorDev
Copy link
Collaborator

Great! And do note that the watcher tests are a bit weird. They're flaky when using short delays, but longer delays suck for dev-feedback loops, so it starts with shorter delays and retries the tests a few times with increased delays on failure

Just in case the logs for the failed tests look confusing

@Valentin271
Copy link
Contributor Author

Alright good to know, I'm currently looking at the tests and I'm suspecting the delay is too short.

@CosmicHorrorDev
Copy link
Collaborator

CosmicHorrorDev commented Dec 20, 2023

Found this issue thread. Looks like it could be relevant (specifically that write events may be getting lost when using the debouncer on macos)

notify-rs/notify#150 (comment)

@CosmicHorrorDev
Copy link
Collaborator

I just pushed a commit that should fix the sanity file watching tests since it looks like we were ignoring Create events and that was the only one getting sent

Aside: trace logs are currently getting filtered out from tests, but I'm starting to think that it'd be a good idea to retain them still

@CosmicHorrorDev
Copy link
Collaborator

Eh went ahead and changed that too. We really need all the info we can get when it comes to CI-driven development 🙃

Copy link
Collaborator

@CosmicHorrorDev CosmicHorrorDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is green. Hope you didn't mind all the commits 🥳

I'm happy to merge this as-is. Most of the issues seem to stem from MacOS sending create events instead of modify events when using the debouncer from some reason

@Valentin271
Copy link
Contributor Author

We really need all the info we can get when it comes to CI-driven development

Yep, I agree.

Hope you didn't mind all the commits

No problem go ahead.


Most of the issues seem to stem from MacOS sending create events instead of modify

From notify_debouncer_full docs:

Doesn’t emit Modify events after a Create event

I'm happy to merge this as-is

Can confirm it still works, happy to see this merged then :)

@CosmicHorrorDev CosmicHorrorDev merged commit 387108e into Inlyne-Project:main Dec 21, 2023
7 checks passed
@CosmicHorrorDev
Copy link
Collaborator

I want to offer a huge thanks for all your help on this :)

@Valentin271 Valentin271 deleted the fix/file-watcher-multiple-events branch December 21, 2023 08:13
@Valentin271
Copy link
Contributor Author

You're welcome, I'm glad I could help. This is a great tool that I really love and want to help with and see grow (or at least not abandoned).

@CosmicHorrorDev
Copy link
Collaborator

There are plenty of things to work on to say the least. I can tag you in some issues that may be easier to start out with

@CosmicHorrorDev CosmicHorrorDev added the C-bug Category: Something isn't working label Dec 22, 2023
@Valentin271
Copy link
Contributor Author

I've seen a few already, but I wouldn't mind if you tagged the good first issues.

@CosmicHorrorDev
Copy link
Collaborator

Keep in mind that features don't have to be perfect to open a PR. I'm more than happy to help with draft PRs. From looking over the issues I see:

I picked those because they're either well tested or generally well isolated

I also have a lot of other things in an obsidian notebook, so I can start opening issues for those over the next few days. Feel free to reach out in whichever issues you want to take on so that we can talk about the general design/approach

@CosmicHorrorDev
Copy link
Collaborator

Opened some new issues that include a lot of potentially good starter issues along with actually labeling easy(ish) issues

https://github.com/trimental/inlyne/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Live render partially working
2 participants