You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ErrorBoundary gets error with "Unexpected error" message instead of actual returned error from loader [only prod build, navigation with useNavigate]
#5115
skvortsovstepan
changed the title
ErrorBoundary gets error with "Unexpected error" message instead of actual returned error from loader [only prod build, navigation with useNavigate]]
ErrorBoundary gets error with "Unexpected error" message instead of actual returned error from loader [only prod build, navigation with useNavigate]
Jan 17, 2023
This is intended behavior. Error Boundaries are for unexpected error scenarios, stuff like "cannot read property 'x' of undefined," and therefore in production builds they are all converted to generic Unexpected Server Error messages. If you want to short circuit from a loader for a known reason, like Unauthorized, then you should throw a Response to your CatchBoundary. In this case, it sounds like you want to throw a response with a 401 status.
What version of Remix are you using?
1.10.1
Steps to Reproduce
Hi there!
Thanks for the awesome framework!
The issue is related to error passed into the ErrorBoundary in case of
useNavigate
usage only onprod
build:useNavigate
prod
buildEnv:
MacOS Monterey 12.5.1
node 18.12.1
npm 8.19.2
Here are steps to reproduce:
npx create-remix@latest
- install basic version of remix with express server (and typescript)app/routes
following files (index.tsx, test.tsx):and
prod
build withnpm run build
npm run start
localhost:3000
and clickGo to test
Expected Behavior
The error message in ErrorBoundary is the message that was thrown from loader:
"Error from api!"
If run dev build with
npm run dev
- it is the case, it is working correctActual Behavior
The error message shown is
"Unexpected Server Error"
in prod buildThe text was updated successfully, but these errors were encountered: