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

zlib: check callbacks are functions #2596

Closed
wants to merge 2 commits into from

Conversation

mtharrison
Copy link
Contributor

This PR attempts to resolve issue #2397
It's based off the PR at: nodejs/node-v0.x-archive#6525

I have added tests too. This is my first contribution so please let me know if I missed something out.

@@ -209,7 +209,8 @@ function zlibBuffer(engine, buffer, callback) {
function onError(err) {
engine.removeListener('end', onEnd);
engine.removeListener('readable', flow);
callback(err);
if (util.isFunction(callback))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

util.isFunction is deprecated, please use a typeof comparison

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed.

@targos targos added the zlib Issues and PRs related to the zlib subsystem. label Aug 28, 2015
@Fishrock123
Copy link
Contributor

Hmmm, I didn't look at the original PR in any great detail when I tagged it. When the callback isn't a function isn't this a no-op?

@@ -0,0 +1,9 @@
'use strict';
var common = require('../common');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make these three lines use const instead of var.

@mtharrison
Copy link
Contributor Author

Are you asking if it should be a no-op, or if it is now?

I don't know the code too well but it looks like it will still do all the deflate but just not try to call a callback. I'm not actually sure why that's useful though tbh.

@Fishrock123
Copy link
Contributor

I don't know the code too well but it looks like it will still do all the deflate but just not try to call a callback. I'm not actually sure why that's useful though tbh.

Yeah, that's what I'm saying, I'm pretty sure you can't get data out of it without a callback, so I'm not sure this is actually useful. :/

@mtharrison
Copy link
Contributor Author

Ok it seems like we agree. I figured this was useful for some reason I don't know about. Happy to close if it's not needed.

@Fishrock123
Copy link
Contributor

Closing. Not providing a callback here is effectively a bug in user code.

@mtharrison thanks for the contribution, even if this ended up not being useful. Lets us check another issue off! :)

@mtharrison
Copy link
Contributor Author

No worries :) I might have a go at another one of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
zlib Issues and PRs related to the zlib subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants