[Bug]: Loader data gets undefined when an error is thrown in a child route
See original GitHub issueWhich Remix packages are impacted?
remix(Remix core)
What version of Remix are you using?
1.0.3
Steps to Reproduce
I couldn’t reproduce the bug with the remix template on Codesandbox, but this happens 100% of the time with the Remix Jokes tutorial. You can watch the bug in action at this moment in @kentcdodds’s lifestream yesterday. He asked if someone could open up an issue for it, so here I am.
I have created a public repo on Github with the code you are supposed to have when you have been following along the Jokes tutorial, just before beginning the “SEO with Meta tags” part. Here’s how to see the bug in action:
- Clone this repo
- Run
npm i - Create a .env file and add
DATABASE_URL="file:./dev.db"in it, along withSESSION_SECRET="whatever" - Seed the DB:
npx prisma db seed - Run the app:
npm run dev - Click “Read jokes”, then “Add your own” (or go to http://localhost:3000/jokes/new)
- Submit the form
- Kaboum!
Expected Behavior
An error thrown in a route action should be caught by the route’s error boundary (or the closest one above). The parent’s loader data shouldn’t become undefined when this happens.
Actual Behavior
The error occurring in the /jokes/new route action function isn’t handled by the route’s error boundary, instead, the /jokes route loader data becomes undefined, triggering an error that is caught by the root error boundary:
TypeError: Cannot read property 'user' of undefined
at `{data.user ? (` (./app/routes/jokes.tsx:50:16)
[...]
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:22 (9 by maintainers)

Top Related StackOverflow Question
I’ve added empty
CatchBoundarytoroutes/jokes.tsxlike this and it fixed it for me.Not sure why
Hi, Is there a fix for it (not a temporary fix)? If not, in the meanwhile, can you add the temporary fix to the docs?