An error in `MetaFunction` or `LinkFunction` is not caught by `ErrorBoundary`
See original GitHub issueWhat version of Remix are you using?
1.4.1
Steps to Reproduce
Create a MetaFunction with an error inside:
export let meta: MetaFunction = () => {
throw new Error("boom")
}
Or create a LinkFunction:
export let links: LinkFunction = () => {
throw new Error("boom")
}
This can happen if, for example, you access a property of data that doesn’t exists.
Expected Behavior
It should show the ErrorBoundary from the route or parent route.
Actual Behavior
It shows a Unexpected Server Error
white screen with black text and the error message below.

Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:5 (2 by maintainers)
Top Results From Across the Web
ErrorBoundary not catching error thrown by imported function
In your code, the error is thrown from an event handler (addPlaylistToSpotify) so componentDidCatch can't catch the error.
Read more >Error Boundaries - React
Error boundaries are React components that catch JavaScript errors ... As of React 16, errors that were not caught by any error boundary...
Read more >React Error Boundaries: Complete Guide - Meticulous
A complete guide to implementing React Error Boundaries, and how to use a third-party tool for handling more sophisticated scenarios.
Read more >A Beginners Guide to Remix Framework - Bejamas
The error boundary template will be rendered in place of the actual component or route, and this error will only affect that component...
Read more >Catching Asynchronous Errors in React using Error Boundaries
If we run this code, the ErrorBoundary will catch the error, ... Abramov on “Throwing Error from hook not caught in error boundary”...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is a problem for me as well, I just wanted to add that for me the real error happened in the LoaderFunction and the MetaFunction threw an error when trying to access that data.
Do we want errors in the MetaFunction to actually trigger the ErrorBoundary? The application can probably render ok most of the time and fall back to a parent MetaFunction.
This is what I did in my application to handle this for now.
This will fall back to the parent MetaFunction if an error in just the MetaFunction, and if the error is actually in a LoaderFunction that ErrorBoundary is activated.
I have just encountered this, and I find it quite odd that
data
is the thrown error instead of the expected type. I got around this by checkingdata instanceof Error
before using properties ondata
. Would be nice not to do this for every meta function.