Empty formdata body stalls the parser
See original GitHub issueNo full example yet, but the basic steps to reproduce would be this from a browser:
var xhr = new XMLHttpRequest();
var fd = new FormData();
fd.append('file', new Blob(), 'file.txt');
xhr.open('POST', '/');
xhr.send(fd);
The file
event is raised correctly, but it seems to never emit a finish
. I suspect the first empty file to be encountered will stall the whole upload request.
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Express body-parser req.body with formdata is empty object
To log every field in formData let myForm = document.getElementById('myForm'); formData = new FormData(myForm); for (let [key, ...
Read more >Node.js Undici
The body mixins are the most common way to format the request/response body. ... .text() mixin first and then manually parse the text...
Read more >Uploading an object using multipart upload - Amazon Simple ...
You can use the multipart upload to programmatically upload a single object to Amazon S3. For more information, see the following sections.
Read more >Karate | Test Automation Made Simple.
Karate will attempt to parse the raw HTTP response body as JSON or XML and make it available as the response value. If...
Read more >XmlHttpRequest - Http requests in Excel VBA (Updated 2022)
A simple POST request to send form data : ... Read : Parse HTML in Excel VBA – Learn by parsing hacker news...
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 FreeTop 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
Top GitHub Comments
@BlaM An easier way is to just do
file.resume()
if you want to skip over the current file.Adding that in this module would not be acceptable however since
busboy
cannot make any assumptions about what the consumer of this module is doing. Adding adata
handler or calling.resume()
will cause the stream to flow. If someone needs to perform an async operation before reading from the file, they would lose data. All (“streams2” or newer) streams since node v0.10 start in a paused state. FWIW a similar issue may arise if you only read part of the file stream, sincebusboy
also handles backpressure properly.Okay, I guess I start to understand now. There NEEDS to be someone listening to the file - if that does not happen, it will never reach “end”:
So if you do THIS:
This will freeze and stop doing things.
You need to at least have someone listening to “data”:
Adding this line into multipart.js right before the
file.on("end")
event fixed the problem for me, too. It should be in the code using busboy - but maybe having this blank “fallback data handler” in busboy itself might avoid confusion?