-
Notifications
You must be signed in to change notification settings - Fork 28.4k
formData with app router: Upload error: TypeError: Failed to parse body as FormData. #73220
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
Possibly related? nodejs/undici#3676 |
Yes it might be related |
Are you able to downgrade Node.js to the 18-20 range, and test? |
@icyJoseph i just tested with Node 18.20.5 and things are getting even stranger. If i upload a file <2GB everythings is working as before, if the file is >2GB for example 2.65GB i am not getting any exception but the process will stuck right after the let formData = await request.formData(); and will hang forever without any message.
|
Before I dive into this further, does it happen with simple fetch? I suspect there's some Buffer allocation going on, https://stackoverflow.com/a/8974841, but it is just an early guess... |
Same issue using native fetch. Looks like the new node release ( 23.3.0 ) increased the buffer to 8192 TB, the 18.20.5 got it capped at 4 GB. Still the issue is present in both versions.
|
This comment has been minimized.
This comment has been minimized.
I am experiencing the same issue with our React Native project. I have already tried running it with a normal Bun server, and React Native is working fine. Additionally, I have tested with different Node versions (v20.13.1 and v22.2.0), but the issue persists. Interestingly, the functionality works fine when tested with Insomnia. |
Update as of Node 24.0.2 - still the same issue
some useful refs https://philna.sh/blog/2025/01/14/troubles-with-multipart-form-data-fetch-node-js/ |
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/twilight-flower-v6pl9s
To Reproduce
i am uploading a file using axios in a client side component in this way:
in the /api/upload route i have the following code:
if the file is <~2GB everythings is working, the formData is returned with the correct values, otherwise if the file is bigger i get the following output:
Current vs. Expected behavior
I expect always to have the formData returned despite the file size
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
i tried also to update to next 15.0.3 and i have the same exact issue.
The text was updated successfully, but these errors were encountered: