Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ Socket.prototype.connect = function() {
initSocketHandle(this);
}

if (cb !== null) {
if (cb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the best approach is probably to check if typeof cb === 'function'.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was also going to suggest that. Yes.

Copy link
Author

@vincent-tr vincent-tr Mar 15, 2017

Choose a reason for hiding this comment

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

I think we need to check if cb is undefined, to respect API contract: net.connect(options[, connectListener])

I don't think that net.connect(options, 42) or net.connect(options, 'anything')
should silently ignore the second parameter without failure, what do you think ?

this.once('connect', cb);
}

Expand Down