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.

busboy doesn't error when over limit?

See original GitHub issue

I’ve got a busboy with options:

var busboyParser = busboy({
    limits: {
        fileSize: 1000000,       // 1 mb
        files: 2,
    }
});

My code is basically from the README:

    if (req.busboy) {
        req.busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
            var saveTo = path.join(os.tmpDir(), path.basename(fieldname));
            console.log("saved to " + saveTo);
            file.resume();
        });
        req.busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated) {
            console.log('Field [' + fieldname + ']: value: ' + val);
        });
        req.busboy.on('finish', function() {
            console.log('Done parsing form!');
        });
        req.busboy.on('error', function() {
            console.log("ERROR");
        });
        req.pipe(req.busboy);
    }

But if I upload a file that’s over 1MB or upload more than 2 files, busboy won’t throw any errors. Instead busboy just proceeds to process the file(s):

Field [flowChunkNumber]: value: 3
Field [flowChunkSize]: value: 1048576
Field [flowCurrentChunkSize]: value: 1048576
Field [flowTotalSize]: value: 8210139
Field [flowIdentifier]: value: 8210139-guidepdf
Field [flowFilename]: value: guide.pdf
Field [flowRelativePath]: value: guide.pdf
Field [flowTotalChunks]: value: 7
saved to /tmp/file
Done parsing form!

How should I handle errors relating to the defined limits?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
sam1111commented, Mar 23, 2016

There is no event for fileSize limit?

0reactions
mscdexcommented, Mar 23, 2016

@sam1111 You can simply unpipe busboy from the source stream if you want to halt parsing and possibly call busboy.removeListener('finish', myFinishListener).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoiding further processing on busyboy file upload size limit
I'm trying to set an upload limit in busboy. Without upload limit i'm able to upload the file successfully. But when i want...
Read more >
busboy - npm
A streaming parser for HTML form data for node.js. Latest version: 1.6.0, last published: 8 months ago. Start using busboy in your project ......
Read more >
@fastify/busboy | Yarn - Package Manager
Description. A Node.js module for parsing incoming HTML form data. This is an officially supported fork by fastify organization of the amazing library ......
Read more >
Fix "Unexpected field" Error From Multer - Maxim Orlov
By now you've already spent several hours trying to solve this problem. Why does implementing a simple file upload feature have to be...
Read more >
Node.js Express File Upload Rest API example using Multer
uploading File to a static folder in the Server (restrict file size: 2MB) ... use middleware function for file upload; catch Multer error...
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