-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Throwing 400 in Client Action Throws as 500 #12919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On a similar note, when a clientLoader returns a call to data() (instead of throwing), like so:
The data returned will be similar to what @kevinbailey25 describes. So, when getting the data inside the component, using
A big issue, also, is that the typescript definition is wrong, saying we only need to write fetcher.data.wow, which is not the case. |
Simple fix: Swap out |
Why does |
@timdorr the documentation tells you to https://reactrouter.com/how-to/error-boundary#3-throw-data-in-loadersactions I get that there's a work around, but this is still an issue and should be fixed, or documentation should be changed. |
Fixed in #13522, will be available in the next release |
I'm using React Router as a...
framework
Reproduction
Go to https://stackblitz.com/edit/github-ff4pz9xc?file=README.md
I have 4 routes,
loader
,action
,client-loader
andclient-action
.Each of these do the same thing:
(exception: the action routes have a form with a button to trigger the action)
I've added a
console.log(error)
in the error boundary.View each error in the console, you'll note that all of them are 400 errors, except the
clientAction
is a 500 error, where thedata
is the fullDataWithResponseInit<{ wow: boolean; }>
instead of just{ wow: boolean }
System Info
Used Package Manager
npm
Expected Behavior
Throwing a 400 error in a clientAction should be a 400 error, and not a 500 error that wraps my 400 error.
Should function the same in
clientAction
as it does inloader
,action
, andclientLoader
Actual Behavior
The
clientAction
throws aErrorResponseImpl
with the status of 500, where it'sdata
prop is my throwndata({ wow: true }, { status: 400 })
callThe text was updated successfully, but these errors were encountered: