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
I verified that the issue exists in the latest next-safe-action release
Is there an existing issue for this?
I have searched the existing issues and found nothing that matches
Describe the bug
When calling a server action with a request body size exceeding 1 MB (as limited by the bodySizeLimit in serverActions), the error is not caught by error.serverError. Instead, it throws an uncaught exception, breaking the expected error handling flow.
Reproduction steps
Set up a server action using next-safe-action.
Send a request with a body larger than 1 MB.
Observe that the error is not handled by error.serverError and instead throws an uncaught exception.
Expected behavior
When the request body size exceeds the limit, the error should be caught and processed by error.serverError, ensuring consistent error handling and avoiding unhandled exceptions.
When the body size limit error occurs, the catch block is never reached, even without next-safe-action defined actions:
This means there's no way for this library to catch that error (or at least, I haven't found any way), because it seems to be thrown at a higher level. I expected this behavior because next-safe-action catches all server errors and puts them inside the serverError prop, except from the framework ones that need to be rethrown (like navigation errors).
So I don't think there's a way to catch this error, but if I (or you, or someone else) find it, I'll then implement it.
Are you using the latest version of this library?
Is there an existing issue for this?
Describe the bug
When calling a server action with a request body size exceeding 1 MB (as limited by the bodySizeLimit in serverActions), the error is not caught by error.serverError. Instead, it throws an uncaught exception, breaking the expected error handling flow.
Reproduction steps
Expected behavior
When the request body size exceeds the limit, the error should be caught and processed by error.serverError, ensuring consistent error handling and avoiding unhandled exceptions.
Link to a minimal reproduction of the issue
https://github.com/aymericfontaine/reprod-nextsafeaction-bodysizelimit
Operating System
macOS
Library version
7.9.9
Next.js version
15.0.3
Node.js version
20.15.0
Additional context
No response
The text was updated successfully, but these errors were encountered: