-
Notifications
You must be signed in to change notification settings - Fork 7.3k
fix(zlib) add check is callback is function #6525
Conversation
Add check is callback is function to prevent next error. zlib.js:160 callback(err); ^ TypeError: undefined is not a function at Unzip.onError (zlib.js:160:5) at Unzip.EventEmitter.emit (events.js:95:17) at Zlib._binding.onerror (zlib.js:298:10)
Thank you for contributing this pull request! Here are a few pointers to make sure your submission will be considered for inclusion. Commit coderaiser/node@d8ed749bea4b831a73586643b4905d94ac80c9ef has the following error(s):
The following commiters were not found in the CLA:
You can fix all these things without opening another issue. Please see CONTRIBUTING.md for more information |
Hey! Thanks for contributing, although I can't accept this change, I have a suggestion for you. Please take a look at https://github.com/joyent/node/blob/master/lib/fs.js#L91, ideally this could could be moved to Does it sounds interesting to you? Or would it be better for me to open an issue and work on it myself instead? Please let me know what you think about it. |
I think that is good idea, but would be better if you will wok on it by yourself. I'm not so good at node sources for now. |
Not sure if a single check is worth factoring out into a separate method. FWIW, the change itself looks acceptable to me but please see CONTRIBUTING.md for hints on what the commit log and tests cases should look like. |
@bnoordhuis we have a lot of such places in core, I think we will generally benefit from sharing this function between them. |
@@ -185,13 +185,18 @@ function zlibBuffer(engine, buffer, callback) { | |||
function onError(err) { | |||
engine.removeListener('end', onEnd); | |||
engine.removeListener('readable', flow); | |||
callback(err); | |||
if (util.isFunction(callback)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please omit braces here.
Let's land it ;) |
Well.. never seems to have landed :-( @indutny ... any other thoughts on this? @coderaiser ... if you're still interested in getting this landed, unless @joyent/node-tsc feel that this is something we should land in v0.12, it may be best to close this here and open it against master in http://github.com/nodejs/node (which is now the active development stream) |
@jasnell after a year I could only say that it needs a test. Other than that - everything is still looking good (except those braces) |
Closing this here as its not going to be able to land in master. If this is going to land, it needs to be a new PR against http://github.com/nodejs/node. I've opened an issue to track. |
Add check is callback is function to prevent next error.
I have one suggestion. Could be used construction like this:
Like it's done here. So there is would be less code.