fix(watcher.node): Normalize paths and improve Node watcher robustness: restart/rescan on errors (including ENOSPC), clear stale state, and remove legacy throttler

This commit is contained in:
2025-12-11 19:13:35 +00:00
parent 0bab7e0296
commit da77d8a608
4 changed files with 54 additions and 73 deletions

View File

@@ -80,11 +80,20 @@ The Node.js watcher has been refactored with elegant patterns inspired by [choki
- Encapsulates file tracking and inode management
- `dispose()` method freezes object to catch use-after-cleanup bugs
**Throttler Pattern:**
- More sophisticated than simple debounce
- Tracks count of suppressed events
- Returns `false` if already throttled, `Throttler` object otherwise
- Used for change events to prevent duplicate emissions
**Path Normalization (v6.3.1+):**
- ALL paths are normalized to absolute at entry points
- Prevents relative/absolute path mismatch bugs
- `watchPath()`, `handleFsEvent()`, `scanDirectory()` all resolve paths
**Restart Rescan (v6.3.1+):**
- When watcher restarts, it rescans the directory
- Catches files created during the restart window
- Clears stale DirEntry data before rescan
- Clears pending unlink timeouts to prevent stale events
**ENOSPC Handling (v6.3.1+):**
- inotify limit errors now trigger watcher restart
- Previously only logged error without recovery
**Atomic Write Handling:**
- Unlink events are queued with 100ms delay