Commit Graph
1 Commits
Author SHA1 Message Date
CatoandClaude Opus 5 ec8ab647a2 fix(errors): a deploy under an open tab recovers itself, and a crash in the browser reaches us (#972)
"Something went wrong. There was a problem loading this page." was the app's
answer to two different situations, and it was the wrong answer to both.

A DEPLOY IS NOT A BROKEN PAGE. Every release replaces the build's hashed
chunks and its server-action ids, so a tab opened a minute earlier asks for
things that no longer exist. The journal for 2026-09-11 01:29 shows eight
"Failed to find Server Action. This request might be from an older or newer
deployment." in one minute — each one shown to a person as a broken page with
a "Try again" button that re-rendered the same stale tab and failed
identically. `isDeploySkewError` recognises that class (server actions, chunk
and dynamic-import failures), and both boundaries reload ONCE instead,
showing "Updating to the latest version" while they do. The one-reload guard
matters as much as the reload: if the page fails again within 30 seconds it
was never skew, so the real error is shown rather than a page that flickers
forever. A genuine failure is never reloaded away.

A CRASH IN THE BROWSER REACHED NOBODY. `setErrorSink` exists in utils/logger
for exactly this and had no caller, so an error boundary logged to the
visitor's own console and the server learned nothing — which is why "some
pages show Something went wrong" could not be turned into a list of pages.
Now: POST /api/client-errors writes one structured line per crash into the
journal beside every other server error (`source: "client"`), fed by both
boundaries, window.onerror and unhandled rejections. Deduped per distinct
error, capped per session, keepalive so a report survives the reload, and
every field clipped — a crash report must never be able to cause one.

The error UI also shows the digest now, so a person can quote a reference
that matches a log line instead of describing a grey page.

Verified: pnpm run verify green — 3069 tests, including 17 new ones that pin
which errors are skew, which are emphatically not, and that a second failure
inside the window stops reloading.


Claude-Session: https://claude.ai/code/session_01WSNERoZZqW2TgqbAGHSQZf

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 06:46:48 -07:00