Repository navigation
fix: report a directory that appeared while no watcher listened to the watcher attaching next - #361
Conversation
…e watcher attaching next
🦋 Changeset detectedLatest commit: b0ec512 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughDirectoryWatcher now records the safe time for each noticed directory and removes that record when the directory is marked missing. When a target has no file entry, a watcher with a start time greater than 1 can use the recorded directory time. Added tests cover directory reporting across paused and newly attached watchers, polling, and retries after directory removal. Priority: ⬇️ Low Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #361 +/- ##
==========================================
- Coverage 92.87% 92.76% -0.12%
==========================================
Files 8 8
Lines 1404 1409 +5
Branches 421 423 +2
==========================================
+ Hits 1304 1307 +3
- Misses 94 96 +2
Partials 6 6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
A local coverage run of Generated by Claude Code |
Summary
webpack pauses its watcher during a build. When the build ends, it attaches a new watcher with the build's start time and closes the paused one. Anything the paused watcher saw in between is dropped. For files, the new watcher catches up by comparing the file's time with the start time ("outdated on attach"). Directories had no stored time, so a watched missing directory that appeared during the build, e.g. a nested
node_modules, was never reported. The rebuild waited for some unrelated change.This was found through webpack's
runtimes (deno)job, which runs the watch tests with polling.WatchCacheUnaffectedTestCases › cache › managedPathfailed about 1 run in 20 under load, on watchpack 2.6.1 and 2.6.2 alike. Native watching can hit it too; polling widens the window.The fix:
DirectoryWatcherkeeps, per directory, the time it was noticed (directorySafeTimes).watch()uses that time when the target is a known directory.1to wait for a directory to (re)appear. They are excluded. Otherwise a removed directory that the parent still lists fires that watcher at once, and the retry loops forever.Tests
test/DirectoryOutdatedOnAttach.test.js:mainThe full suite passes natively (213) and with
WATCHPACK_POLLING=200, file by file.npm run lintis clean.Checked in webpack under Deno, 40 runs under load: the missed change and the hangs are gone. The remaining failure there is a separate webpack issue:
experiments.cacheUnaffecteddoes not re-resolve a module when only a missing directory appears. I'll take that up in webpack.Generated by Claude Code
Summary by CodeRabbit