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

feat(watch): migrate to fsnotify #2048

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat(watch): migrate to fsnotify #2048

wants to merge 1 commit into from

Conversation

andreynering
Copy link
Member

@andreynering andreynering commented Feb 8, 2025

We're migrating from watcher to fsnotify, which is more performant and will avoid issues with high CPU usage.

This will close the following issues:

TODO:

  • fsnotify recommends us to watch directory instead of individual files.
    • Add a function to internal/fingerprint to return only the directories and watch for those.
    • When an event comes, we'll need to double check if the file is included in sources.
  • Mark the --interval flag and interval: setting as deprecated. We should probably emit a warning if set, as from now on these will be ignored.
    • I actually reconsidered this and I'm reusing the interval setting as the time we wait for suplicated events. Chanegd default from 5 seconds to 100ms.
  • Dedup duplicated events
  • Write blog post
  • Take this comment in consideration when testing: Task is not getting re-executed after addition/deletion of files when used with --watch argument.  #1179 (comment)

@andreynering andreynering added the area: watcher Changes related to the Taskfile watcher. label Feb 8, 2025
@andreynering andreynering self-assigned this Feb 8, 2025
@andreynering andreynering changed the title feat(watcher): migrate to fsnotify feat(watch): migrate to fsnotify Feb 8, 2025
@andreynering andreynering force-pushed the fsnotify branch 4 times, most recently from 07524dd to 09f9211 Compare February 9, 2025 23:54
@andreynering andreynering marked this pull request as ready for review February 18, 2025 01:24
Copy link
Member

Choose a reason for hiding this comment

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

I'm having issues where if a directory is empty when I start the watcher and then create files, nothing will be detected. If I create any file before starting the watcher, then other new files are detected.

I'm also not able to get deletes to work (on Linux). When I remove a file, I just get something like this:

task: received watch event: WRITE         ".../testdata/watcher_interval/src/foo.txt"
task: skipped for file not in sources: src/foo.txt

But it does not start the task.

Copy link

Choose a reason for hiding this comment

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

I'm having issues where if a directory is empty when I start the watcher and then create files, nothing will be detected. If I create any file before starting the watcher, then other new files are detected.

I've observed the same thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm still going to work on this issue another day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: watcher Changes related to the Taskfile watcher.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants