Weird issue(s) with fetch from endpoint and multipart file content
See original GitHub issueDescribe the bug
After NPM update have some issues with uploading multipart form content including a file. This used to work fine.
Now get MultipartParser.end(): stream ended unexpectedly when trying the same code in a js endpoint.
Also after this error repeated actions seem not to forward the multipart form data
Reproduction
Just do form submit with multipart content to a js endpoint.
Try to forward that to another server like https://kit.svelte.dev/docs/routing#endpoints-body-parsing mentioned here.
` export async function post({ url,request, event,locals}) { const data= await request.formData();
const nftsReq = await fetch( 'someurl', {
method: 'POST',
body: data
})
`
Happens with each first upload. The forwarded request seems without data. Seems like the fetch behavior changed?
Logs
MultipartParser.end(): stream ended unexpectedly
Error: MultipartParser.end(): stream ended unexpectedly
at MultipartParser.end (file:///C:/Users/mvanh/source/repos/DeSo/nftz/nftz-front/node_modules/@sveltejs/kit/dist/chunks/multipart-parser.js:326:10)
at toFormData (file:///C:/Users/mvanh/source/repos/DeSo/nftz/nftz-front/node_modules/@sveltejs/kit/dist/chunks/multipart-parser.js:440:9)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async post (C:\Users\mvanh\source\repos\DeSo\nftz\nftz-front\src\routes\api\account\uploadimage.js:4:17)
at async render_endpoint (file:///C:/Users/mvanh/source/repos/DeSo/nftz/nftz-front/.svelte-kit/runtime/server/index.js:269:19)
at async resolve (file:///C:/Users/mvanh/source/repos/DeSo/nftz/nftz-front/.svelte-kit/runtime/server/index.js:3345:11)
at async Object.handle (/C:\Users\mvanh\source\repos\DeSo\nftz\nftz-front\src\hooks:72:12)
at async respond (file:///C:/Users/mvanh/source/repos/DeSo/nftz/nftz-front/.svelte-kit/runtime/server/index.js:3290:20)
at async file:///C:/Users/mvanh/source/repos/DeSo/nftz/nftz-front/node_modules/@sveltejs/kit/dist/vite.js:2324:22
System Info
Windows, Vercel, latest npm update version
Severity
serious, but I can work around it
Additional Information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:22 (4 by maintainers)
Top Results From Across the Web
How do I POST with multipart form data using fetch?
You're setting the Content-Type to be multipart/form-data , but then using JSON.stringify on the body data, which returns application/json .
Read more >Solved: Post File via HTTP - Power Platform Community
If you want to post multipart form data with binary content via the HTTP connector you must format the body of the request...
Read more >Get upload information to perform a multipart file upload.
Get upload information to perform a multipart file upload. get https://api.cloudsmith.io/v1/files/ {owner} / {repo} / {identifier} /info/.
Read more >Handling file uploads - Manual - PHP
The following code assumes that the mime type is in $type, and that you have loaded the file's contents into $content. If the...
Read more >How to perform multipart requests in Go - freshman.tech
In this article, you'll learn how to make multipart related requests in Go using standard library packages.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am still having this issue. 1.0.0-next.391. Trying to post a PDF and the formData being sent in the body is coming through empty. Was working before switch to POST
It’s working now with the latest update.