Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multer (1.0.3) hangs single / multi file upload #213

Closed
siyb opened this issue Aug 20, 2015 · 5 comments
Closed

multer (1.0.3) hangs single / multi file upload #213

siyb opened this issue Aug 20, 2015 · 5 comments

Comments

@siyb
Copy link

siyb commented Aug 20, 2015

version: 1.0.3

Multer sometimes hangs on file uploads, predominantly, when multiple files are uploaded, but it's also reproducible with single file uploads. I've tracked the issue to make-middleware.js, when multer hangs readFinished is false and the busboy "finish" callback is never called. I have tried uploading multiple as well as single files using request (2.61.0) and superagent (1.3.0). Strangely enough, I was not able to reproduce this issue using curl or httpie, so maybe this issue isn't entirely (or at all) related to multer or busboy. Here is my "testcode" (relevant parts):

superagent:

 var files = ['filepath','filepath',...];
 var r = superagent
                    .post(serviceUrl)
                    .field('someField', 'value');

                _.map(files, function (i) {
                    return fs.createReadStream(i);
                }).forEach(function (file) {
                    r.attach('upload', file);
                });

                r.end(function (err, res) {
                    if (err) {
                        return reject(err);
                    } else {
                        return resolve(res);
                    }
                });

request:

                var formData = {
                    upload: _.map(files, function (i) {
                        return fs.createReadStream(i);
                    }),
                    someField: 'value'
                };

                request.post({url: serviceUrl, formData: formData}, function (err, res, body) {
                    if (err) {
                        logger.error('Error uploading file', err);
                        reject(err);
                    } else {
                        resolve({res: res, body: body});
                    }
                });

multer:

var uploadFile = upload.array('upload'); // using storage with standard stuff, all callbacks are called properly
@siyb
Copy link
Author

siyb commented Aug 24, 2015

might be related to #205

@DarianAnjuhal
Copy link

I had the same fight two days ago:

Try this:

var req = request.post({url: url}, function optionalCallback(err, httpResponse, body) {

        //DO STUFF        
          });

          var form = req.form();
          form.append('file', fs.createReadStream(pathToFile));

Please let me know if you know more about this issue.

@siyb
Copy link
Author

siyb commented Aug 25, 2015

@DarianAnjuhal: thanks for the advise, I've rewritten the code to use native curl bindings now, this issue has disappeared. If I find the time, I will try it your way and report back to you ;)

@qlqllu
Copy link

qlqllu commented Sep 9, 2015

I have the same issue. I use postman to post a file, the server uses multer to parse multipart form.
I can upload the file at first, but if I post some times, the server will hang and never respond.

@LinusU
Copy link
Member

LinusU commented Sep 19, 2015

This should be fixed by #205 and released on npm as version 1.0.5 🚀

Please reopen if issue persists.

@LinusU LinusU closed this as completed Sep 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants