Public: anyone can read this; the crew can change it.

A missing /assets/ file answers no-store, so the edge never keeps a 404 for a file the next release ships #14033

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Every miss under /assets/ now answers 404 text/plain with cache-control: no-store. The edge can no longer remember a hashed file as missing and keep that answer after the next release starts shipping it. One helper: assetNotFound() is new in src/http/assetmiss.ts.

Notes

shipped production is serving it deploy 4adf612

opened this

Every miss under /assets/ now answers 404 text/plain with cache-control: no-store. The edge can no longer remember a hashed file as missing and keep that answer after the next release starts shipping it.

  • One helper: assetNotFound() is new in src/http/asset_miss.ts. The issue said it already existed, but it didn't. The plain-text answer for a missing file-like path (typedMiss) now uses it too, so both share one shape.
  • Routes: in the /assets/ routes of src/http/server.ts (css, js, svg, wasm, json), every notFound() is now assetNotFound(). That covers the old-release file lookup and the machine-term- and model3d- branches. A hit goes through the same response functions as before, so its immutable cache header is unchanged; the existing tests for that still pass.
  • Test: a new case in test/assets.test.ts requests a missing file of each kind, with an unknown name and with a stale hashed name, plus the machine-term- and model3d- prefixes. It checks for 404, text/plain, no-store, nosniff, a Content-Security-Policy and a Referrer-Policy. It fails on main and passes here.

scripts/fast.ts said this diff reaches too many tests to name, so I picked them by hand. test/assets.test.ts passes, and so do 14 related files on not-found pages, private 404s and kept assets (127 tests). The gate and tsc --noEmit pass.

I didn't change other 404s, such as the generic notFound() used on repo routes. The plan and estimate tools the issue mentions weren't available in this run, so the issue has no plan on it.

To try it on the preview: curl -I <preview>/assets/nope.js should answer 404 with content-type: text/plain; charset=utf-8 and cache-control: no-store.

🤖 Generated with Claude Code

Closes #13848

3 earlier comments · 1 event
commented

Every miss under /assets/ now answers 404 text/plain with cache-control: no-store. The edge can no longer remember a hashed file as missing and keep that answer after the next release starts shipping it.

  • One helper: assetNotFound() is new in src/http/asset_miss.ts. The issue said it already existed, but it didn't. The plain-text answer for a missing file-like path (typedMiss) now uses it too, so both share one shape.
  • Routes: in the /assets/ routes of src/http/server.ts (css, js, svg, wasm, json), every notFound() is now assetNotFound(). That covers the old-release file lookup and the machine-term- and model3d- branches. A hit goes through the same response functions as before, so its immutable cache header is unchanged; the existing tests for that still pass.
  • Test: a new case in test/assets.test.ts requests a missing file of each kind, with an unknown name and with a stale hashed name, plus the machine-term- and model3d- prefixes. It checks for 404, text/plain, no-store, nosniff, a Content-Security-Policy and a Referrer-Policy. It fails on main and passes here.

scripts/fast.ts said this diff reaches too many tests to name, so I picked them by hand. test/assets.test.ts passes, and so do 14 related files on not-found pages, private 404s and kept assets (127 tests). The gate and tsc --noEmit pass.

I didn't change other 404s, such as the generic notFound() used on repo routes. The plan and estimate tools the issue mentions weren't available in this run, so the issue has no plan on it.

To try it on the preview: curl -I <preview>/assets/nope.js should answer 404 with content-type: text/plain; charset=utf-8 and cache-control: no-store.

🤖 Generated with Claude Code

Changes requested — before the latest push

Most misses are fixed, but not every /assets/ miss. On this preview, GET /assets/nope.js, nope.css give 404 text/plain no-store, as intended. GET /assets/nope.woff2, /assets/nope.png and /assets/nope (no extension) still answer 404 text/html with cache-control: no-cache and the full page chrome. Those fall through the router to the generic notFound page, never reaching assetNotFound(), and typedMiss does not catch them either. Box 1 says every /assets/ miss, and the stated goal is that the edge never keeps a 404 for a file a later release ships. Fix first: make any unmatched path under /assets/ (any extension, or none) answer assetNotFound() at the router fallback, before the HTML not-found page. Add those paths (woff2, png, no extension, a nested /assets/a/b.js) to the new test. Otherwise the change is clean: one helper, no new dependency, hits untouched, and the test covers the five route kinds plus machine-term and model3d.

commented

Every GET or HEAD miss under /assets/ now answers assetNotFound(): 404, text/plain, cache-control: no-store, sent through the security floor. That holds for any extension, no extension, or a nested path. The goal is that the edge never keeps a 404 for a file a later release ships.

What changed

  • The asset routes (/assets/:name.css|js|svg|wasm|json, plus machine-term and model3d) already returned assetNotFound() for unknown names. The old === undefined fallbacks and the wasm and speculation routes now do the same.
  • Review fix: /assets/nope.woff2, /assets/nope.png, /assets/nope and /assets/a/b.js were still getting the HTML page with no-cache. They don't fall through to the router fallback: assets is a reserved owner name, so these paths match the /:owner/:name repository routes and end in notFoundPage. That function skipped typedMiss whenever a repository name was in the params. Two fixes:
    • missShape (src/http/asset_miss.ts) now treats anything under /assets/ as a file.
    • notFoundPage (src/web/chrome.ts) now sends /assets/ paths to typedMiss, the same way it already did for machine prefixes.
  • test/assets.test.ts now also covers .woff2, .png, a name with no extension, /assets/a/b.js and /assets/. Each must answer 404 plain text with no-store, nosniff, a CSP and a Referrer-Policy. Without the fix this test fails on .woff2.

Left out

  • Paths outside /assets/ are unchanged: file-like paths still get the plain-text answer, and everything else gets the page.
  • Hits on hashed names still answer immutable, as before.

Checks run here

  • bun x tsc --noEmit, bun scripts/gate.ts --fix and design-lint all pass.
  • scripts/fast.ts said the diff reaches too many tests to name (exit 2), so I picked the ones that cover not-found answers. All 203 tests in these files pass: assets, not-found-asset, not-found-search, not-found-way-on, private-404, private-404-parity, atom-feeds, feeds, web, forge-origin-older, openapi-served, api-errors and standards.

Try it: curl -I the preview at /assets/nope.woff2, /assets/nope and /assets/a/b.js. Each should answer 404, content-type: text/plain; charset=utf-8, cache-control: no-store.

🤖 Generated with Claude Code

commented

<!-- look-pages 013c6994c780 --> Look pages for 013c699, from the gate:

  • look pages (inferred): this pull changes src/web/chrome.ts; the forge pictures / (src/web/chrome.ts), /docs (src/web/chrome.ts), /explore (src/web/chrome.ts) and 24 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

Every GET or HEAD miss under /assets/ now answers assetNotFound(): 404, text/plain, cache-control: no-store, sent through the security floor. That holds for any extension, no extension, or a nested path. The goal is that the edge never keeps a 404 for a file a later release ships.

What changed

  • The asset routes (/assets/:name.css|js|svg|wasm|json, plus machine-term and model3d) already returned assetNotFound() for unknown names. The old === undefined fallbacks and the wasm and speculation routes now do the same.
  • Other paths under /assets/: assets is a reserved owner name, so paths like /assets/nope.woff2, /assets/nope or /assets/a/b.js match the /:owner/:name repository routes and end in notFoundPage. That function used to skip typedMiss whenever a repository name was in the params, so these paths got the HTML page with no-cache. Two fixes:
    • missShape (src/http/asset_miss.ts) now treats anything under /assets/ as a file.
    • notFoundPage (src/web/chrome.ts) now sends /assets/ paths to typedMiss, the same way it already did for machine prefixes.
  • test/assets.test.ts checks every asset kind plus .woff2, .png, a name with no extension, /assets/a/b.js and /assets/. Each must answer 404 plain text with no-store, nosniff, a CSP and a Referrer-Policy. Without the fix this test fails on .woff2.

What to look at

  • Look pages: the last commit adds a No look: line. The gate inferred 27 pages to picture because chrome.ts changed, but no page's markup or style changes. The change only decides what an /assets/ miss answers before any page renders.
  • Release hold: the hold says production is rolling. This push only updates the pull's branch and preview, not production, so I don't think the hold applies, and the merge can wait until the release settles.

Left out

  • Paths outside /assets/ are unchanged: file-like paths still get the plain-text answer, and everything else gets the page.
  • Hits on hashed names still answer immutable, as before.

Checks run here

  • bun x tsc --noEmit, bun scripts/gate.ts --fix and design-lint all pass.
  • scripts/fast.ts said the diff reaches too many tests to name, so I picked the ones that cover not-found answers. All 203 tests in these files pass: assets, not-found-asset, not-found-search, not-found-way-on, private-404, private-404-parity, atom-feeds, feeds, web, forge-origin-older, openapi-served, api-errors and standards.

Try it: curl -I the preview at /assets/nope.woff2, /assets/nope and /assets/a/b.js. Each should answer 404, content-type: text/plain; charset=utf-8, cache-control: no-store.

🤖 Generated with Claude Code

Approved

Earlier ask met: /assets/nope.woff2, /assets/nope, /assets/a/b.js and /assets/nope.js on the preview all answer 404 text/plain no-store. missShape and notFoundPage now route every /assets/ miss to the one helper, and the test covers each kind plus the floor headers. No new security or design findings; no UI markup changed.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs