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

net: fix error details in connect() #514

Closed
wants to merge 1 commit into from
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
15 changes: 8 additions & 7 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
assert.ok(self._connecting);

var err;
var ex;

if (localAddress || localPort) {
var bind;
Expand All @@ -788,7 +789,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
err = bind(localAddress, localPort);

if (err) {
var ex = exceptionWithHostPort(err, 'bind', localAddress, localPort);
ex = exceptionWithHostPort(err, 'bind', localAddress, localPort);
Copy link
Member

Choose a reason for hiding this comment

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

Declaring the var upfront is not really necessary (it gets hoisted anyway) and it makes the diff more noisy than it really needs to be.

self._destroy(ex);
return;
}
Expand All @@ -813,14 +814,14 @@ function connect(self, address, port, addressType, localAddress, localPort) {
}

if (err) {
self._getsockname();
var sockname = self._getsockname();
var details;
if (self._sockname) {
ex.localAddress = self._sockname.address;
ex.localPort = self._sockname.port;
details = ex.localAddress + ':' + ex.localPort;

if (sockname) {
details = sockname.address + ':' + sockname.port;
}
var ex = exceptionWithHostPort(err, 'connect', address, port, details);

ex = exceptionWithHostPort(err, 'connect', address, port, details);
self._destroy(ex);
}
}
Expand Down