-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
docs: invalid status code in middleware #4212
Comments
This is an interesting point. Feel free to open a PR proposing a fix as it should be quite a simple piece, we have #3496 (drop a note in there too) coming up and it seems a very sensible breaking change to me for now you can work around the behaviour in errorFormatter |
If the above doesn't align what we do in practice or in the docs, we should fix it ☺ |
So it sounds like we may need a reproduction @alishi973, are you able to share any extra details or code? |
Yeah, that's right, I've used is it possible to rename or change that to avoid any confusion? BTW, Thanks for your time ✌️ |
Area of Improvement
The TRPC documentation suggests that middleware can throw a
TRPCError
instance with a specific status code set to return an appropriate error response to the client.However, there is a bug (or maybe using invalid tools) where all errors thrown from middleware are caught by TRPC and returned as a generic "Internal Server Error" response with a
500
status code, regardless of the specific status code set in the TRPCError instance.IMO, This behavior is incorrect and may be confusing for developers and end-users.
Could you provide guidance on how to work around this issue until it is resolved, or suggest an alternative solution that would allow middleware to return appropriate error responses with specific status codes?
Link to related docs
https://trpc.io/docs/server/middlewares
Additional information
No response
👨👧👦 Contributing
The text was updated successfully, but these errors were encountered: