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

dicer writable never ends if bad multipart #2

Closed
golyshevd opened this issue Feb 21, 2014 · 4 comments
Closed

dicer writable never ends if bad multipart #2

golyshevd opened this issue Feb 21, 2014 · 4 comments

Comments

@golyshevd
Copy link

stream.pipe(dicer); never fired dicer 'end' event if broken multipart passed.

I had to write this code to solve the problem

stream.on('data', function (chunk) {
    dicer.write(chunk);
});

dicer.on('end', function () {
    dicer.__ended__ = true;
   //  ok
});

stream.on('end', function () {
    dicer.end();
    if ( dicer.__ended__ ) {
        return;  
    }

    // ERROR
});

I expected SyntaxError or another on 'error' dicer event

@mscdex
Copy link
Owner

mscdex commented Feb 21, 2014

Ok, this should be fixed in the master branch -- an error event will be emitted. Note that I've also changed the 'end' event for Dicer to 'finish' to keep in line with the documented events for a Writable stream.

@golyshevd
Copy link
Author

Thank you! It works! And another similar issue. If Readable stream emits an error, I expect that dicer Writable will stop parsing and emit this error on themself instance and should not emit 'finish' if any 'error' event emitted

@mscdex
Copy link
Owner

mscdex commented Feb 22, 2014

@golyshevd I looked at Writable's code in node core while I was working on this and from what I can tell 'finish' is still emitted even when 'error' is emitted. So I was trying to keep that same behavior.

@golyshevd
Copy link
Author

hm, surprising, anyway, thanks!

@mscdex mscdex closed this as completed Feb 23, 2014
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