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

small: a not-found page is small: the 404 answer weighs under 3 KB, not 10.7 KB #14332

Merged opened this

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

Merged

A not-found page now renders as a short page of about 1 KB, down from 10.7 KB, with no navigation or script. It carries the message, the home link (and Sign in when signed out), the escaped path, the search box and the request id.

Notes

shipped production is serving it deploy 2f48880

opened this

A not-found page now renders as a short page of about 1 KB, down from 10.7 KB, with no navigation or script. It carries the message, the home link (and Sign in when signed out), the escaped path, the search box and the request id.

I did not take before/after screenshots, so the "Looks" requirement is met only by naming /nope/nothing in a commit line.

  • What changed: notFoundPage in src/web/chrome.ts now builds its answer with a new src/web/lean_page.ts instead of the full layout. The page links the cached hashed stylesheet and sets a tight Content-Security-Policy (default-src 'none'). It also sets X-Content-Type-Options, Referrer-Policy and no-store, and securityFloor still runs on the way out. API and machine-path 404s keep their JSON shape, unchanged.
  • Tests: test/not-found-page.test.ts has a new test asserting the answer is under 3,000 bytes, has no <script or <nav, still has the search form and home link, and carries the floor headers. In test/not-found-asset.test.ts I changed three checks that asserted the old behaviour (body.length > 2000, "still render the full page") to < 3000. Those assertions were what the issue asks to reverse.
  • Checks: bun x tsc --noEmit is clean. bun scripts/gate.ts passes. I ran test/not-found*, test/private-404*, test/a11y-landmarks.test.ts and test/guide.test.ts (103 pass, 0 fail) plus test/feature-orphans.test.ts. scripts/fast.ts named 2,307 test files, so I did not run them all; the forge's check will. bun scripts/design-lint.ts reports no findings in the files I touched; the other findings it prints are existing ones in src/web/style/components.ts.
  • What I left out: there is no terminal screen for the 404, so the commit says "No door". The page also drops the shell's cached etag and edge cache, because it is no-store. I judged that fine for a miss, but it is a choice.
  • How to try it: open /nope-404 on the preview and view source.

🤖 Generated with Claude Code

Closes #14276

Show 8 earlier items

7 earlier comments
commented

The failures this pull caused are fixed and pushed. Three tests still fail here, and they fail identically on main (3 fail with my changes stashed).

Cause: my last round changed the 404 page's text. The page no longer has a 404 heading, and the home link read Go to the forge home. Five tests in web-origins, web.test.ts and not-found-search looked for those strings.

Fix:

  • The link reads Go home again. The Go to the forge home wording was my reading of juniper's finding about the forge name. The · forge title still carries the brand, and I updated test/not-found-page.test.ts back too.
  • The three web.test.ts assertions that looked for 404 now look for Nothing here, the h1.

Checked: web-origins, web.test.ts, not-found-search, not-found-page and pull-check-again pass here, and tsc and gate.ts are clean.

Still failing: stuck-pile, keeper-measures and deadends (the "findings are the known ones" test), which the check log also reports as red on main. I left them alone.

Not reproduced: the pull-check-again failure ("a writer queues a check and gets the run") did not reproduce here, so I think it was flaky.

commented

I made no change this round. The gate note on abceb67 only says that this pull touches src/web/chrome.ts and src/web/lean_page.ts and that a commit names /nope/nothing, so the look pages get captured for it. It asks for no fix. It is also about an older commit: the branch head is 7985dc5, already pushed, with nothing uncommitted.

The pull as it stands:

  • What changed: an unknown page now answers a short document from src/web/lean_page.ts, about 1 KB instead of 10.7 KB. It has no script and no navigation. It keeps the floor headers and its own Content-Security-Policy. API paths still get the JSON 404.
  • Page contents: one <h1>Nothing here</h1>, the muted line, Go home and Sign in as btn(...) links, search, the "Try" suggestions, and the request id. It sets theme-color for light and dark.
  • Cache: the page sends private, max-age=0 instead of no-store.
  • Tests: the KNOWN_404 list in test/forge-webspec.test.ts keeps one reason per finding. Tests that looked for 404 in the body now look for Nothing here.
  • Not done: I left out a README line naming the cache choice, because the README has no 404 section.
  • Still failing: stuck-pile, keeper-measures and deadends fail the same way on main, so they are not from this pull.
  • Try it: curl -i $PREVIEW/nope/nothing. The preview is at https://lab--14332--forge-trevato-apps.open-platform.sh.
commented

<!-- look-pages 7985dc59390e --> Look pages for 7985dc5, from the gate:

  • look pages (named): this pull changes src/web/chrome.ts, src/web/lean_page.ts; a commit names /nope/nothing
commented

The 404 page is now a small page: the src/web/lean_page.ts change from the earlier commits is untouched. The check failed on the "pipeline first" gate rule, and I added a commit message line it accepts.

  • What I changed: an empty commit whose message carries Direction: a small 404 page is the visible fix users hit now, ahead of pipeline items (#14276). I changed no code.
  • Why that line: the pull adds a feature and no pipeline change, so the gate wants a Direction: line naming the issue it serves.
  • What I ran: bun scripts/gate.ts now passes, with only the existing notes. I did not rerun tsc or the tests, since nothing in the code changed.
  • Left alone: the over-100-column comments in four test files, which the gate says the nightly rewrap handles on main.
  • Left alone: the gate's "look pages" note, which only mentions a commit naming /nope/nothing.
  • Pushed: bcc26ab92, so the check will rerun on the pull.
commented

No code change this time, and I pushed nothing. The look-pages comment is an informational note from the gate. It isn't a failing check, and bun scripts/gate.ts passes.

The note says the pull changes src/web/chrome.ts and src/web/lean_page.ts, and that one commit (faf899fbe) names /nope/nothing in its Looks: line. That path is deliberate. It is a URL that doesn't exist, so the look the gate takes of it is the new small 404 page, which is what this pull changes.

To try it, open /nope-404 on the preview and view source. The page should be a short document, under 3 KB, with no shell or script.

commented

I merged main into the branch and pushed it (28bf0a296). The only conflict was in test/error-page-500.test.ts.

The conflict: it was in the test "no Accept header, a wildcard, or a mutation gets JSON, not a page". My branch posted to /boards/new, and main posts to /welcome. I kept main's version.

Checks run:

  • bun x tsc --noEmit and bun scripts/gate.ts --fix show nothing to fix.
  • 114 tests pass across the 10 not-found and error-page test files, including test/error-page-500.test.ts.
  • test/error-page.test.ts also passes.

Not run: bun scripts/fast.ts named 2335 of 3776 test files for this diff, so I picked the covering tests by hand and left the full check to the forge.

commented

<!-- look-pages 28bf0a2966d2 --> Look pages for 28bf0a2, from the gate:

  • look pages (named): this pull changes src/web/chrome.ts, src/web/lean_page.ts; a commit names /nope/nothing
commented

I made no change and pushed nothing for this one. The background task notification was the earlier broad fast.ts test run, which I had already replaced with the targeted tests.

The look-pages comment is the same automated note as before, now for 28bf0a2. It is informational, and bun scripts/gate.ts passes. It points at /nope/nothing, named in the Looks: line of commit faf899fbe. That path is a missing URL, and the page the gate takes of it is the new small 404, which is what this pull changes.

I'm not editing the commit message. That would mean rewriting history on a pushed branch, and the note asks for no fix.

To see it, open /nope-404 on the preview and view source.

Approved

The preview /nope-404 answers 404 in 1,403 bytes: one h1, one muted line, Go home and Sign in as real links, a search form with a label, a skip link, no script, no nav. It sends the CSP, nosniff and same-origin referrer headers. An API path still answers the JSON 404. Earlier asks (btn components, single h1, theme-color, per-finding KNOWN_404 reasons, cache wording) are met; the later commits only fixed tests and merged main. Next, non-blocking: (1) keep the Asked-for line and search value in the same row on a 360px phone and check the input is at least 44px tall; (2) add a one-line README-free note in docs/features/not-found-page.md on why the page is private, max-age=0.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs