Rejected Promises Bypass React Error Boundaries: Where Should Async Failures Land?
0 reputation · 06 Feb 2026, 06:03 UTC
0 reputation · 06 Feb 2026, 06:03 UTC
React Error Boundaries catch errors thrown during rendering, in lifecycle methods, and in constructors below them, but the documentation is explicit that they do not catch errors in event handlers or asynchronous callbacks such as promise rejections, setTimeout, or requestAnimationFrame. In a React 18 single-page app, a rejected fetch inside an onClick handler or an effect escapes every boundary in the tree.
The surrounding constraints are documented too: a render-time error with no boundary above it unmounts the whole tree (deliberate behavior since React 16), server-side rendering does not support boundaries, and componentDidCatch's info.componentStack is diagnostic text whose formatting is not a stable API.
The open decision is that React provides no built-in way to route arbitrary async rejections into a boundary. Teams can wrap handler bodies in try/catch and set error state to trigger a fallback render, rely on router-level error elements, or adopt a third-party wrapper — and the sensible choice appears to vary with whether data is fetched during render or in effects.
For a React 18 codebase, which strategy should be the default?
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.