Skip to content

fix(tools): canonicalize watch root so relative paths receive events - #3115

Open
amitcoder79 wants to merge 1 commit into
0xPlaygrounds:mainfrom
amitcoder79:fix/watch-relative-paths
Open

amitcoder79 wants to merge 1 commit into
0xPlaygrounds:mainfrom
amitcoder79:fix/watch-relative-paths

Conversation

@amitcoder79

Copy link
Copy Markdown

Fixes #3109

Local.watch(relative_path, ...) returned Ok(Watch) but silently dropped every event. The same path made absolute worked correctly.

Root cause

notified() stored the caller-provided root as-is into the Filter. The notify crate's OS-level watchers (inotify, FSEvents) deliver events with absolute paths. Filter::keeps() then compared:

  • File case: absolute_event_path == relative_stored_path → always false
  • Directory case: absolute_event_path.strip_prefix(relative_root) → always Err → false

Every event was silently rejected, and since send_batches only sends non-empty batches, nothing ever reached the Watch stream.

Fix

Canonicalize root at the top of notified() using the existing crate::fs::real_path, which calls std::path::absolute and resolves symlinks. This ensures the stored root matches event paths regardless of how the caller spelled the path.

What changed

One file, 5 added lines:

let root = crate::fs::real_path(root);
let root = root.as_path();

Testing

All 5 existing watch tests pass. The fix is exercised by any test or caller that passes a relative path to Local.watch.

Cassettes

Not applicable (no provider interaction).

Changelog

  • fix(tools): Local.watch now correctly delivers events when called with relative paths

The notify crate delivers events with absolute paths from the OS, but
notified() stored the root path as given. A relative root never matched
absolute event paths in Filter::keeps(), silently dropping every event.

Canonicalize the root via real_path() before storing it, so strip_prefix
and equality checks work regardless of how the caller spelled the path.

Fixes 0xPlaygrounds#3109
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

Successfully merging this pull request may close these issues.

bug(tools): Local.watch silently drops events for relative file and directory paths

1 participant