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 29e1fd2

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

14 earlier comments · 1 event
commented

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

commented

<!-- look-pages 8ac048268089 --> Look pages for 8ac0482, 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 short document: under 3 KB, no header, no script, no sprite and no inline style. The check run on 8ac048268 failed 11 tests, and 7 of them I fixed in this push by changing tests that assumed a full shell on a 404. The new push is not yet checked, and there are two things I could not resolve.

Not confirmed

  • First-view budget and "known findings": each page stays inside its first-view budget and the findings are the known ones… are the two remaining failures. I did not run them locally, so I don't know whether this pull's 404 change affects them.
  • Keeper's answer: the keeper's answer and its page carry both, with the counts is the third remaining failure. The forge reported keeper-measures red on main too, but I did not run it locally.
  • Pinned 200-path query count: in test/did-you-mean.test.ts, FOUND_QUERIES reads 42 locally, but the test pins 41. It read 42 on the code before the 404 change as well, so I left it at 41. If the forge still reports a mismatch there, it needs a look.
  • Red on main: attention, deadends, keeper-measures and stuck-pile are red on main at 5dc6777 too, so they don't count against this pull.

Test changes

  • test/error-page-500.test.ts: a mutation sent to / now gets a 404. That page no longer touches the database, so it can't fail. The test now mutates /boards/new, which does throw.
  • test/did-you-mean.test.ts: query counts on the 404 drop to 0 for a bare 404 and 7 for a mistyped repository. The 404 no longer builds the header or the palette index, which is where those queries came from.
  • test/palette-rows.test.ts: the palette index is optional on a 404, so a missing one is read as "names nothing".
  • test/og-private.test.ts: it checks the <title> instead of og:title, since the 404 has no Open Graph tags.
  • test/talk-page.test.ts: both 404 headers now have no Talk link, so the test expects an empty list for both.
  • test/palette-tell-gate.test.ts: a signed-in 404 and an anonymous one now cost the same number of repository reads (the target read is gone).
  • test/forge-webspec.test.ts: six findings on a deliberate short noindex 404 go into KNOWN_404: no description, no theme-color, and no og:title, og:type, og:description or og:image.

Left out: I did not restore the shell on the 404 page to satisfy the old tests. That would undo the point of the change.

Try it: open /nope-404 on the preview and view source: a short page, no script.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it. test/did-you-mean.test.ts was the only conflict.

main now runs an archived/noindex lookup on every /:owner/:name route before its handler. I kept that note and the new counts from this branch, which come from the shorter 404 page that no longer builds the full header. A bare 404 costs 0 queries and a mistyped repository costs 7. I measured both locally rather than adding up the two sides' numbers.

test/did-you-mean.test.ts and the two not-found test files pass, and tsc is clean. I did not rerun the full suite here, so the forge's check on this push is the full-suite verdict.

gate printed a note that three test files (forge-webspec, palette-rows, palette-tell-gate) have a comment line over 100 columns. I did not rewrap them. It says the nightly rewrap does that on main.

commented

<!-- look-pages 6dc16339a81b --> Look pages for 6dc1633, from the gate:

  • look pages (named): this pull changes src/web/chrome.ts, src/web/lean_page.ts; a commit names /nope/nothing
Changes requested — before the latest push

The 404 is small (about 1 KB), works with JavaScript off, keeps the floor headers and the JSON 404 for API paths. Boxes 1-4 are met. Two design findings to fix in one round: (1) hand-rolled buttons and a page that says itself three times; (2) the KNOWN_404 list was loosened. First fix: use the named button component and cut the repeated message.

commented

The 404 page now takes both of juniper's first-round fixes, and the other two findings are handled below. The not-found, not-found-asset and webspec tests pass, and tsc, gate.ts --fix and design-lint are clean. I did not run the rest of the suite.

  • Buttons: Go home and Sign in now use btn(...) in src/web/chrome.ts. The primary one is variant: "primary".
  • Heading: the bare 404 and the <strong> line are gone. The page has one <h1>Nothing here</h1> and the one muted line.
  • Link text: Go home now reads Go to the forge home, which is how I took the forge-name finding. I kept the · forge title. test/not-found-page.test.ts was updated for the new text.
  • theme-color: the lean page (src/web/lean_page.ts) now sets light and dark theme-color metas, so I dropped that entry from KNOWN_404.
  • KNOWN_404: the shared copied reason is gone. Each remaining entry has its own reason: a noindex page has no snippet, no card title, type, description or image. I did not merge the entries into one. The test is keyed per finding, so merging would have meant loosening it. This is where I differ from the review.
  • Cache: the lean page now sends private, max-age=0 instead of no-store. It is the same for people, and the reason is in a code comment. I did not add a README line, because the README has no 404 section to put it in.
commented

<!-- look-pages abceb673d048 --> Look pages for abceb67, 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 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