Repository navigation
fix: treat a file where a watched directory should be like a missing directory - #360
Conversation
🦋 Changeset detectedLatest commit: 3cc37aa 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.doScan now handles ENOTDIR from fs.readdir as a directory-removal condition. A regression test covers watching foo/index.js when foo initially exists as a file, then becomes a directory containing index.js. The test checks for a change event and no console errors. A patch changeset describes the scenario. Priority: ⬇️ 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 #360 +/- ##
=======================================
Coverage 92.72% 92.73%
=======================================
Files 8 8
Lines 1403 1404 +1
Branches 420 421 +1
=======================================
+ Hits 1301 1302 +1
Misses 96 96
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:
|
Supersedes #226 (thanks @liximomo for the report and analysis).
With
resolve.alias: { "@/foo": ["src/foo/index", "src/foo"] }and a file atsrc/foo, enhanced-resolve correctly reportssrc/foo/index,src/foo/index.js, … as missing dependencies: ifsrc/foolater becomes a directory, webpack must re-resolve. watchpack then creates aDirectoryWatcherforsrc/foo, and itsreaddirfails withENOTDIR:onScanErrorlogsWatchpack Error (initial scan): ENOTDIR: not a directory, scandir '…/src/foo'(on every poll with polling);src/footo become a directory, sosrc/foo/index.jsappearing later is never reported (native watching).#226 only hid the log line. This PR treats
ENOTDIRonreaddirlikeENOENT: the directory is not there yet, so watchpack watches the parent and creates the watcher once a directory appears. This is the existing missing-directory path, including its retry for a path that is not a directory yet (#342).Verified
mainlogs theENOTDIRerror, and this PR logs nothing. Both rebuild from file → error → directory. Here webpack also watchessrc/fooitself (the alias's second target), which hides the lost event.foo/index.jswhilefoois a file, and thenfooreplaced by a directory withindex.js:mainENOTDIRerror loggedchangeforfoo/index.jsTests
test/MissingUnderFile.test.jscovers the case above. It fails onmainand passes here, with and withoutWATCHPACK_POLLING=200.WATCHPACK_POLLING=200.npm run lintis clean.🤖 Generated with Claude Code
https://claude.ai/code/session_017TkBWTk3wcyUcJYDp5ZhaP
Generated by Claude Code
Summary by CodeRabbit