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

'end' fires twice. #7

Closed
j opened this issue Oct 25, 2013 · 3 comments
Closed

'end' fires twice. #7

j opened this issue Oct 25, 2013 · 3 comments

Comments

@j
Copy link

j commented Oct 25, 2013

code:

  exports.file = function(req, res) {
    var busboy = new Busboy({ headers: req.headers });

    busboy.on('file', function(field, file, filename, encoding) {
      console.log('file');
    });

    busboy.on('field', function(field, val, valTruncated, keyTruncated) {
      console.log('field');
    });

    var end = 0;
    busboy.on('end', function() {
      end++;
      console.log('end: ' + end);
    });

    req.pipe(busboy);
  };

output:

file
end: 1
field
field
end: 2

If I use busboy.once('end') (as in docs), it ends before I get the fields.

How can I know that parsing both fields and files is done using busboy?

@j
Copy link
Author

j commented Oct 25, 2013

Node.js docs state: This event fires when no more data will be provided., so I'd assume it'd get fired once and after complete parsing everything completely.. Am I wrong?

@mscdex
Copy link
Owner

mscdex commented Oct 27, 2013

This should be fixed in master, please give it a try now.

@j
Copy link
Author

j commented Oct 29, 2013

Yep, re-running my test seems to work now.

Good work!

@j j closed this as completed Oct 29, 2013
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

2 participants