[Server actions] Error: Body exceeded 1mb limit #49891
SummaryI am using server actions for file uploads. When trying to upload a file bigger than 1MB, the following error is being raised by the Next server: error Error: Body exceeded 1mb limitI tried the old way of exporting config, which seem to be deprecated. export const config = {
api: {
bodyParser: {
sizeLimit: '8mb',
},
},
}Is there a way I can increase the body size limit for server actions? Additional informationNo response ExampleNo response |
Replies: 5 comments 7 replies
|
As of now I don't see any way to set body limit programmatically. For testing purposes you can change limit value in const actionData = await parseBody(req, "10mb") || ""; // Changed limit to 10mb |
|
This feature has been blocked since You need to customize the The file is located in I've opened PR #51104 to resolve this hard-coded size issue. UPDATEResolved with #51104 Reference |
|
on your next.config.js From: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions |
|
there's always a maximum amount of data that can uploaded using server actions, and if surpassed it throws an error to the console and there's no way to catch it and handle it gracefully. Correct me if i'm wrong. I tried this: const handleSubmit = async (formData: FormData) => { i then pass handleSubmit as an action to the form but it doesn't work. |
|
I spent an hour trying to catch this error but regardless of including the try/catch blocks client-side and server-side, I can't catch it. When my client component calls the server action it throws the uncaught error on the server and hangs until the timeout limit. The server logs: I have increased my server action body size limit, but it is unfortunate this error can't seem to be caught and reported back to the frontend in a meaningful way. If I'm wrong and there is a way, please let us know. |

@kasipavankumar
serverActiionsBodySizeLimithas been added on release v13.4.8.