You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(dev): rebuild manifest when public directory is added - #5210
watchPublicDirs (and Vite's watchScanDirs) previously only triggered a rebuild on unlinkDir for public/ directories, so removing and recreating public/ left the dev worker's #nitro/virtual/public-assets-data manifest stale and serverFetch returning 404 even while external disk requests worked.
Changes:
Trigger build:reload on both addDir and unlinkDir for publicDirs in watchPublicDirs() (src/build/build.ts), and onChange() in watchScanDirs() (src/build/vite/_scan-watch.ts).
Add a regression test in test/unit/dev-scan-reload.test.ts verifying serverFetch serves recreated public/ assets after public/ is removed and recreated.
No actionable comments were generated in the recent review.
Walkthrough
Public-directory watchers now handle both directory additions and removals. A dev-server test checks that an asset becomes unavailable after removal and is served again after restoration.
Both watcher paths trigger reload handling for matching public-directory additions and removals. The dev-server test checks asset availability before removal, after removal, and after the asset is recreated.
Issue 5122 describes stale public-asset behavior related to the watcher logic changed here.
Possibly related PRs
nitrojs/nitro#5190: Changes the same watcher behavior and manifest lookup for stale public assets.
nitrojs/nitro#5120: Introduces the public-directory watchers that this change extends to handle additions.
nitrojs/nitro#5208: Changes the same watcher and adds a regression test for the same stale-manifest issue.
Merge Risk: Minimal · up to aacca
In development, recreating the public directory now triggers a reload, so assets are served again through serverFetch without an unrelated source edit. No concrete merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title uses conventional commit format (fix(dev): prefix with scope and description). It names the main change: the manifest is rebuilt when a public directory is added. The changeset adds addDir h…
Description check
The description is related to the changeset. It states the fix for issue #5200, names the watchers changed in src/build/build.ts and src/build/vite/_scan-watch.ts, and lists the regression test added …
Linked Issues check
[#5200] The issue requires that recreating public/ restores serverFetch access to the asset without an unrelated source edit. The reported cause is that watchPublicDirs in src/build/build.ts r…
Out of Scope Changes check
All changed code stays within the scope of #5200. The src/build/build.ts change widens the existing unlinkDir handler to addDir and unlinkDir for the same public dir set. The `src/build/vite/_…
Full details: Title check
Explanation
The title uses conventional commit format (fix(dev): prefix with scope and description). It names the main change: the manifest is rebuilt when a public directory is added. The changeset adds addDir handling alongside unlinkDir in both watchers, so the title matches the main change. The description also states the rebuild now runs on addDir as well as unlinkDir.
Full details: Description check
Explanation
The description is related to the changeset. It states the fix for issue #5200, names the watchers changed in src/build/build.ts and src/build/vite/_scan-watch.ts, and lists the regression test added in test/unit/dev-scan-reload.test.ts.
Full details: Linked Issues check
Explanation
[#5200] The issue requires that recreating public/ restores serverFetch access to the asset without an unrelated source edit. The reported cause is that watchPublicDirs in src/build/build.ts rebuilds only on unlinkDir, so the dev worker manifest is not refreshed when public/ is recreated. At the reviewed head, watchPublicDirs handles addDir as well as unlinkDir for configured public dirs and calls build:reload. This is the same reload path the issue reports as working after a source-triggered rebuild. The Vite path in src/build/vite/_scan-watch.ts receives the same change, so watchScanDirs also reloads on addDir for public dirs. The PR adds a regression test in test/unit/dev-scan-reload.test.ts that checks serverFetch after public/ is removed and recreated. I did not run that test, and I read the test only from the PR summary. The issue makes no Vite or production acceptance criteria, so the Vite change is not required by the issue. Its behavior is still consistent with the fix.
Full details: Out of Scope Changes check
Explanation
All changed code stays within the scope of #5200. The src/build/build.ts change widens the existing unlinkDir handler to addDir and unlinkDir for the same public dir set. The src/build/vite/_scan-watch.ts change makes the matching edit in the Vite watcher. Both doc-comment edits describe the same behavior. The regression test in test/unit/dev-scan-reload.test.ts covers the reported case. No unrelated changes were identified in the diff inspection. I did not inspect the test file contents directly.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Fix failing CI checks
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 799c2500-dce4-4637-8b1b-396a6943e032
Commits
Reviewing files that changed from the base of the PR and between ccba20b and aaccaf3.
Files selected for processing: 3
src/build/build.ts
src/build/vite/_scan-watch.ts
test/unit/dev-scan-reload.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5200
watchPublicDirs(and Vite'swatchScanDirs) previously only triggered a rebuild onunlinkDirforpublic/directories, so removing and recreatingpublic/left the dev worker's#nitro/virtual/public-assets-datamanifest stale andserverFetchreturning 404 even while external disk requests worked.Changes:
build:reloadon bothaddDirandunlinkDirforpublicDirsinwatchPublicDirs()(src/build/build.ts), andonChange()inwatchScanDirs()(src/build/vite/_scan-watch.ts).test/unit/dev-scan-reload.test.tsverifyingserverFetchserves recreatedpublic/assets afterpublic/is removed and recreated.