Repository navigation
fix(runtime): don't cache missing static asset 404s - #4896
Merged
Merged
Conversation
Upgrade h3 to 2.0.8 and throw static 404s with `cache-control: no-store`, which opts them out of the immutable asset-dir `headers` route rule (h3js/h3#1612).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters: 1
📒 Files selected for processing: 4
✨ Finishing Touches
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. Comment |
pi0
approved these changes
Oct 22, 2026
commit: |
This was referenced Nov 3, 2026
This branch was successfully deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #4891. Since error responses apply
event.res.errHeaders, theheadersroute rule Nitro generates for asset dirs (e.g./build/**) also reaches 404s. A missing file under/build/came back withcache-control: public, max-age=..., immutable, so a CDN or browser could cache the 404 for up to a year (e.g. a hashed chunk requested during a deploy).h3 2.0.8 (h3js/h3#1613, closes h3js/h3#1612) lets an
HTTPErrorthat carries a header in its ownheadersopt out of that rule header. This PR upgrades h3 to^2.0.8, and the static handler now throws its 404s withcache-control: no-store, matching the Vercel preset's existingno-store404 route. The oldevent.res.headers.delete("Cache-Control")calls are removed:event.res.headersis not used for error responses, so they had no effect.Tests:
shows 404 for /build/non-filenow checkscache-control: no-storewhenserveStaticis enabled; it failed onnodebefore the fix. The static middleware unit tests now check the headers on the thrown error.Not covered: presets with
serveStatic: false(e.g. cloudflare-module, cloudflare-pages) don't use the static handler, so a missing asset that reaches the worker still gets h3's no-route 404 with the immutable header. That needs a separate fix.🤖 Generated with AI assistant