Files
Janka UrygaandGitHub ea541987d1 fix: handling of falsey values in error boundaries (#93134)
our error boundaries had a bunch of logic that set `state.error = error`
and then checked `if (state.error)`, which only works correctly if
thrown value is truthy. it breaks if something does e.g. `throw
undefined`. in this case, we would incorrectly think that no error
occurred and render children again (instead of a fallback), which can
then lead to an infinite loop if the children throw again.

the fix is to wrap the thrown value, so `state.error` is either `null`
(initial/reset) or `{ thrownValue: ... }` if something errored. i
initially considered using a separate `state.hasError` boolean, but
that's a bit annoying to type, and really we want to model this as a
discriminated union, so using a pseudo-Optional thing is nicer.
2026-04-29 17:25:56 +00:00

18 lines
362 B
JavaScript

'use client'
export default function GlobalError({ error }) {
return (
<html>
<head></head>
<body>
<h1>Global Error</h1>
<p id="error">{`Global error: ${error}`}</p>
{error?.digest && <p id="digest">{error?.digest}</p>}
</body>
</html>
)
}
// for inspecting purpose
GlobalError.displayName = 'GlobalError'