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

Allow optional custom onFinish handler for Readable constructor. #505

Merged
merged 4 commits into from
Jul 8, 2016

Conversation

vqvu
Copy link
Collaborator

@vqvu vqvu commented Jul 4, 2016

Handle the issue raised in #490 in a disciplined way (by punting to the user). We simply allow an extra argument when wrapping a Readable that handles the onFinish logic for us..

@ronag
Copy link

ronag commented Jul 4, 2016

I would like to suggest to take this one step further. Especially considering how common this issue is. Can't we simply check for instanceof http.IncomingMessage and automatically apply onFinished?

@vqvu
Copy link
Collaborator Author

vqvu commented Jul 4, 2016

That would cause the browserify build to pull in the http package, which I don't want to do, as it bumps up the size of our minified JS from 58.21 kB to 102.59 kB in exchange for just a bit of convenience.

@ronag
Copy link

ronag commented Jul 4, 2016

@vqvu: I see. Isn't there other ways to check for http.IncomingMessage? e.g. if (stream.socket && stream.httpVersion).

Note, I'm actually fine with the proposed solution. I just think that this is quite a big and common "gotcha".

@vqvu
Copy link
Collaborator Author

vqvu commented Jul 4, 2016

That's certainly possible, but I think adding special handling for IncomingMessage is out of scope for the library.

Agreed that this is something of a gotcha. I'm happy to add something to the docs about this though (even though that's not as foolproof). I mention IncomingMessage specifically in the new docs for the stream constructor, and I'm open to suggestions for documentation improvements to make these kinds of issues more visible.

P.S. I'll leave this issue open for a few days so the other contributors can weight in if they so choose. Then I'll merge it and cut a release for you.

@vqvu vqvu force-pushed the extended-on-finish branch 2 times, most recently from 347ce96 to c1c7804 Compare July 5, 2016 00:33
@vqvu vqvu force-pushed the extended-on-finish branch from c1c7804 to 84eade6 Compare July 5, 2016 00:35
@vqvu vqvu merged commit 4db13e9 into caolan:master Jul 8, 2016
@vqvu vqvu deleted the extended-on-finish branch July 8, 2016 07:54
@ronag
Copy link

ronag commented Jul 8, 2016

@vqvu: Could you merge into 3.0.0 branch? That is what I'm currently using.

@vqvu
Copy link
Collaborator Author

vqvu commented Jul 8, 2016

Yeah, I can do that this weekend. I just tried and it's a bit complicated.

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

Successfully merging this pull request may close these issues.

2 participants