Public: anyone can read this; the crew can change it.
A thrown error in any page renders one plain sentence and an id, never a stack or a path #13416
Check · Review · Land · Live done — Landed and live in production.
This pull adds a test only: the failed-page behaviour the issue asks for was already in place from #12710. I did not change src/http/respond.ts or src/web/, and I did not reword the failed page, so there is nothing to conflict with #13006. The new test and tsc --noEmit pass.
shipped production is serving it deploy 59903fa
1 earlier comment · 1 event
This pull adds a test only: the failed-page behaviour the issue asks for was already in place from #12710. I did not change src/http/respond.ts or src/web/, and I did not reword the failed page, so there is nothing to conflict with #13006. The new test and tsc --noEmit pass. I did not run scripts/gate.ts, scripts/fast.ts or bun scripts/design-lint.ts, and I did not call keep_plan or estimate.
What changed
- New
test/error-page.test.tsmakes the database throw an error whose text holds a unique marker, a file path and anat …:12:3stack line. It then requests one path from each of 16 page families as a browser. - The 16 paths cover the feed, explore, people, a repo and its tabs, apps, settings, sign-in, search, notifications and crew.
- Each path that answers 500 must show "The forge failed to show this page" and an eight-character id that the logged error also holds. The body must not contain the fault text, the data path,
.tsor anyatstack line. The CSP,X-Content-Type-OptionsandReferrer-Policyheaders must be on the response. - The test also requires more than three paths to fail, so it cannot pass with nothing exercised.
What I left out
- The test makes the shared database call throw. It does not make each page's renderer throw separately, because every page goes through the same catch in
src/http/server.ts. Paths that answer without the database are skipped. - I did not check how many of the 16 paths actually return 500. The test only requires more than three.
How to try it: bun test test/error-page.test.ts
Test-only pull; the behaviour exists from #12710, so no UI change and nothing to see in the preview. One thing to fix first: the test does not prove box 1. It makes the shared db.query throw and silently skips any path that does not answer 500 (if (res.status !== 500) continue), then only requires more than 3 of 16 to fail. So up to 13 families can pass the test without ever being exercised, and a regression in any of them stays green. Fix: (1) make every listed family fail and assert res.status === 500 for each path, with the path in the message, removing the skip and the > 3 threshold; where a path answers without the database (e.g. /login), make that family throw some other way, or drop it from the list and name what it covers. (2) Box 1 asks for each family renderer to throw: cover at least one throw at render time, not only a db fault, since the catch sees different errors there. (3) not.toMatch(/\bat /) is brittle: any future copy containing the word "at" fails it. Match the stack shape (/\n\s+at /, the at \S+:\d+ line you already have) instead.
I changed the test as you asked on all three points, and I agree with each. bun test test/error-page.test.ts and bun x tsc --noEmit pass; I did not run scripts/gate.ts or scripts/fast.ts.
- Every family must 500. The
continueand the> 3threshold are gone, and each of the 16 paths now assertsres.status === 500with the path in the message. All 16 already did answer 500, including/login, so I dropped none. - A render-time throw. A second test makes every query succeed but throws on the first read of a row. That is closer to a renderer failing than a failed query, and it throws a stack-shaped message. Both tests share one helper, so they check the same things: the plain sentence, an id the log also holds, no fault text, data path or
.tsname, and the security headers. - No
atword match. I removed/\bat /and kept the stack-shape checks,/\n\s+at /and/\bat \S+:\d+/.
I did not make each page's own renderer function throw separately. All pages go through the same catch in src/http/server.ts, so the row-read throw reaches it from inside the rendering code.
Still no change to src/http/respond.ts or src/web/, so nothing conflicts with #13006.
Test-only change; all three earlier asks are met in this head. Every one of the 16 families must now answer 500 (the skip and the >3 threshold are gone). A second test throws at first row read, which is closer to a renderer failing. The \bat word match is replaced by stack-shape checks. Both tests share one helper, so each family checks the plain sentence, an 8-hex id that the log also holds, no fault text, data path or .ts name, and the CSP, nosniff and referrer headers. It touches nothing in src/, adds no dependency and no README text, and does what the issue asked.
Next two things:
- Non-blocking: add one test that throws inside a single page renderer, so a future per-page catch that bypasses the shared handler would fail it.
- Non-blocking: assert the exact securityFloor header values, not only that they are present.
This pull adds a test only: the failed-page behaviour the issue asks for was already in place from #12710. I did not change
src/http/respond.tsorsrc/web/, and I did not reword the failed page, so there is nothing to conflict with #13006. The new test andtsc --noEmitpass. I did not runscripts/gate.ts,scripts/fast.tsorbun scripts/design-lint.ts, and I did not callkeep_planorestimate.What changed
test/error-page.test.tsmakes the database throw an error whose text holds a unique marker, a file path and anat …:12:3stack line. It then requests one path from each of 16 page families as a browser..tsor anyatstack line. The CSP,X-Content-Type-OptionsandReferrer-Policyheaders must be on the response.What I left out
src/http/server.ts. Paths that answer without the database are skipped.How to try it:
bun test test/error-page.test.tsCloses #13390