Course contentsShow
← Web Development
Lesson 1671 of 2,98231. Error Handling and ResilienceFree lesson

Errors That Boundaries Don't Catch

Learning which errors escape boundaries: event handlers, async code, SSR errors, and errors in boundaries themselves.

Errors That Boundaries Don't Catch

You'll learn: Which types of errors slip past error boundaries, leaving you vulnerable to unhandled failures.

Error boundaries are powerful, but they're not omnipotent guardians—they only catch errors during the synchronous rendering lifecycle of your components. Think of them as safety nets positioned under a trapeze, but not around the entire circus tent.

What Escapes Error Boundaries?

Event Handler Errors
When a user clicks a button and your onClick handler throws an error, error boundaries won't catch it. Event handlers execute outside the render cycle, so you need traditional try/catch blocks inside them.

Asynchronous Code
Errors thrown in setTimeout, promises, async/await functions, or API calls happen after rendering completes. By the time they fail, the error boundary's safety net isn't active. You must handle these with .catch() on promises or try/catch in async functions.

Server-Side Rendering (SSR) Errors
If you're rendering on the server, errors during SSR won't be caught by client-side error boundaries. You need server-specific error handling middleware.

Errors in the Boundary Itself
An error boundary can't catch its own errors—that would be like asking someone to lift themselves by their bootstraps. If your error boundary component crashes, you need a parent error boundary wrapping it.

The Analogy

Error boundaries are like airbags in a car: they deploy during a crash (rendering error), but they won't help if you leave the stove on at home (async errors) or forget to wear your seatbelt (event handler errors).

Key Takeaway: Error boundaries only catch synchronous rendering errors—use traditional error handling (try/catch, promise .catch()) for event handlers, async code, and always wrap boundaries with parent boundaries.