cojs / busboy

Busboy multipart parser as a yieldable
154 stars 24 forks source link

It gets stuck if parts were not piped somewhere #25

Closed nettiopsu closed 9 years ago

nettiopsu commented 9 years ago

For unknown reason if parts of the form were not piped to another stream in the same while-loop (like it was done here: https://github.com/koajs/examples/blob/master/upload/index.js), but instead they were collected to array for further working with them out of this while-loop, then it gets stuck after it went through all the variables of the form.

E.g.

var yieldedParts = [];
while (part = yield parts) {
    yieldedParts.push(part);
    console.log('yielded');
}
console.log('went out of while loop');

In this case it will show 'yielded' as many times as you have form variables, but never 'went out of while loop'

jonathanong commented 9 years ago

this is how streams work. you have to consume them otherwise they remain "paused" indefinitely.

krzkaczor commented 8 years ago

You can pipe it to dev-null stream https://www.npmjs.com/package/dev-null