Busboy often throws Unhandled 'error' event Unexpected end of multipart data
See original GitHub issueHi everyone
I am using node v6.10.3 and Busboy 0.2.14. I use busboy to stream jpg image to a node server. But the issue is sometimes it works and some times it fails with the folowing error and crashes my server.
events.js:183 066466+00:00 app[web.1]: throw er; // Unhandled 'error' event 2018-06-19T00:45:07.066468+00:00 app[web.1]: ^ 2018-06-19T00:45:07.066470+00:00 app[web.1]: 066472+00:00 app[web.1]: Error: Unexpected end of multipart data 2018-06-19T00:45:07.066474+00:00 app[web.1]: at /app/node_modules/busboy/node_modules/dicer/lib/Dicer.js:62:28
Here is my code to handle the file
req.busboy.on('file', function (fieldname, file, filename) {
console.log("Uploading: " + (filename));
fstream = fs.createWriteStream(__dirname + '/public/img/'+ filename);
file.on('data', function(chunk) {
fstream.write(chunk);
});
file.on('end', function() {
fstream.end();
console.log('File [' + fieldname + '] Finished sucessfully');
});
file.on('error',function(err){
console.log('fstream error' + err);
file.unpipe();
});
});
I have tried to follow similar issues online, but no success. Can somebody please help me what could be the issue here? Thank you in advance.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Error "Unexpected end of multipart data" in busboy file upload
For me, I received this error when I used \n newlines instead of \r\n newlines when formatting my post body on the client...
Read more >Error "Unexpected End Of Multipart Data" In Busboy ... - ADocLib
I use busboy to stream jpg image to a node server.Busboy often throws Unhandled 'error' event Unexpected end of multipart data #171.
Read more >Error “Unexpected end of multipart data” in busboy file upload
The problem is sometimes it works(file get uploaded succsesfully) and sometimes i get error Unexpected end of multipart data and the application crash....
Read more >Error: Unexpected end of multipart data - Busboy and Dicer
I'm trying to use an endpoint node to upload a file to s3 by form-data. I'm using multer, multer-s3 and express.
Read more >busboy/multipart.js at master - GitHub - SegmentFault
A streaming parser for HTML form data for node.js. ... before busboy's 'finish' event is emitted ... throw new Error('Multipart: Boundary not found');....
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
@trunderman If you still need the answer, you must add an error handler to the file objected got from busboy. You’ll have something like :
Note that the error event will also be emitted on the
busboy
object (sobusboy.on('error', () => { ... })
will also get an event)@david1921 how did you go about handling the error correctly?