fix: suppress stats errors for unstat-able paths in watch-event path#326
fix: suppress stats errors for unstat-able paths in watch-event path#326danielroe wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 999dc1d 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 |
There was a problem hiding this comment.
Pull request overview
This PR extends Watchpack’s existing “permission/invalid-path” error suppression from the initial scan path to the watch-event path, preventing noisy Watchpack Error (stats) logs when lstat fails with known “unstat-able” error codes (e.g. protected Windows system files, unreadable mounts).
Changes:
- Suppress
onStatsErrorlogging forEACCES,ENODEV, and Windows-onlyEINVALduring watch events inDirectoryWatcher. - Add Jest coverage to assert no stats-error logging occurs for these watch-event
lstatfailures. - Add a changeset documenting the patch-level behavior change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/DirectoryWatcher.js |
Suppresses specific lstat error codes in the watch-event path, aligning behavior with initial scan suppression. |
test/DirectoryWatcher.test.js |
Adds regression tests ensuring suppressed lstat errors during watch events do not log Watchpack Error (stats). |
.changeset/silence-stats-errors-watch-events.md |
Documents the patch change in release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| testHelper.tick(500, () => { | ||
| // eslint-disable-next-line jsdoc/reject-any-type | ||
| /** @type {any} */ (fs).lstat = originalLstat; | ||
| a.close(); | ||
| const printed = errorSpy.mock.calls | ||
| .map((call) => String(call[0])) | ||
| .filter((msg) => msg.includes("Watchpack Error (stats)")); | ||
| errorSpy.mockRestore(); | ||
| expect(printed).toEqual([]); | ||
| done(); | ||
| }); |
|
@danielroe Thanks for the PR, can you describe cases when you are getting them? |
|
I think the scenario is that:
you can see in the logs: https://github.com/nuxt/nuxt/actions/runs/29737171552/job/88355542839?pr=35740#step:7:1813 you can ignore mentions of rspack; this PR actually runs webpack but wrongly labels it rspack; I'm fixing this separately. |
Summary
this ignores
EINVAL,EACCESandENODEVlstat errors on watch events, following up on #298we noticed in this in CI (search for EINVAL in the logs)
this is a harmless situation and the fact that we already resolved #187 for initial scan suggests it's safe to do the same for watch events, and with the same motivation.
What kind of change does this PR introduce?
fix
Did you add tests for your changes?
yes
Does this PR introduce a breaking change?
no
Use of AI
I used AI to: