Skip to content

Watcher should ignore files not in sources before cancelling any running tasks.#2743

Open
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/watch-new-files
Open

Watcher should ignore files not in sources before cancelling any running tasks.#2743
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/watch-new-files

Conversation

@trulede
Copy link
Contributor

@trulede trulede commented Mar 15, 2026

Fix several issues with the watcher:

  • the watcher would cancel running tasks before evaluating the watch condition and, if the skip condition existed, not even restart the cancelled tasks.
  • events not being watched would cause running tasks to be cancelled (same root cause as above).
  • a watched dir that was deleted and then recreated would no longer be watched.
  • a new dir created, which should be watched, may not actually be watched.

Additional tests are added to cover most normal conditions.

closes #2477
closes #2715
duplicate #2493
duplicate #2742

watch.go Outdated
e.Logger.VerboseErrf(logger.Magenta, "task: event skipped for being an ignored dir: %s\n", event.Name)
continue
}
if event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename) {
Copy link

Choose a reason for hiding this comment

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

Suggested change
if event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename) {
if event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename) || event.Has(fsnotify.Write) {

Without this I think writes to existing files that are not in the sources would still trigger cancellation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks. I've added that.

@mkeeler
Copy link

mkeeler commented Mar 16, 2026

@trulede Feel free to bring the tests over here if you like. What about the second half to my original PR to fix the task fingerprinting uniqueness issue? Should I refactor my PR to only have that fix within it.

@trulede
Copy link
Contributor Author

trulede commented Mar 16, 2026

@mkeeler I've copied over the watch_tests and will get them running and then update this PR.

Yes, refactor your PR to have the fix for the checksums.

Co-authored-by: Oleg Butuzov <butuzov@made.ua>
Co-authored-by: Timothy Rule <34501912+trulede@users.noreply.github.com>
@trulede trulede force-pushed the PR/watch-new-files branch from 208fe5f to d65f329 Compare March 16, 2026 22:05
@trulede trulede marked this pull request as ready for review March 16, 2026 22:17
@trulede trulede added area: watcher Changes related to the Taskfile watcher. state: reviewed labels Mar 16, 2026
@trulede trulede mentioned this pull request Mar 16, 2026
@trulede trulede changed the title Watcher does not ignore created files that do not match sources. Watcher should ignore files not in sources before cancelling any running tasks. Mar 16, 2026
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. state: reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

watch issue Watch hijacking dependency process

2 participants