question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird issue(s) with fetch from endpoint and multipart file content

See original GitHub issue

Describe 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:closed
  • Created a year ago
  • Comments:22 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
x-GF-xcommented, Jul 22, 2022

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

1reaction
DePasqualeOrgcommented, Jul 19, 2022

It’s working now with the latest update.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found