-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Conversation
Thank you for contributing this pull request! Here are a few pointers to make sure your submission will be considered for inclusion. 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 |
I also went ahead and signed the CLA. |
Thanks for the contribution! I think I'd prefer Also what about moving some of this logic into |
Ok, I can change the string concatenation. That makes more sense. I wasn't sure if moving it would be the direction to go or not. I'll go ahead and try to knock that out. |
alright I moved some of the logic into |
address: req.address | ||
}; | ||
if (req.port) additions.port = req.port; | ||
var ex = errnoException(status, 'write', err, additions); |
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.
why not pass req directly?
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.
I thought it sometimes could have additional properties, like afterShutdown
.
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.
I was looking at https://github.com/joyent/node/blob/master/lib/net.js#L213
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.
We could filter out functions, I'm mostly just looking for a generic way for this to work without having to be too explicit at every callsite
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.
What about building the message from the keys of the object passed to errnoException?
On Mar 10, 2014, at 5:22 PM, Timothy J Fontaine [email protected] wrote:
In lib/net.js:
@@ -769,7 +769,12 @@ function afterWrite(status, handle, req, err) {
}if (status < 0) {
- var ex = errnoException(status, 'write', err);
- err = util.format('%s %s:%s', err || '', req.address, req.port);
- var additions = {
address: req.address
- };
- if (req.port) additions.port = req.port;
- var ex = errnoException(status, 'write', err, additions);
We could filter out functions, I'm mostly just looking for a generic way for this to work without having to be too explicit at every callsite—
Reply to this email directly or view it on GitHub.
didn't look at the diff too closely but we'll have to make sure to support ephemeral ports as well, looks like maybe that's missing |
yep, I'll see if I can get that added tonight. |
just to be clear, you mean Depending on when the error is raised and by the time we've been notified it may not be possible to have that information. The most reliable way would be for us to exercise that path by default, but doing so results in an extra syscall by default |
Yeah, passing |
my point is that the fd may be gone by the time we want that information, so the only reliable way to have that information around is to always ask for that it when the handle is created, which means everyone will feel it -- I'm not opposed to it, it's generally useful, but to date we've so far waited to resolve that information until explicitly asked for it |
Ah ok I see what you're saying. I can only speak for myself there, I'd definitely prefer a tiny performance hit to having logs that have no zero value |
Just curious, what good is knowing the fd after it's been closed? There's |
That's not the question, he wants to know localPort, localAddress, remotePort, and remoteAddress, which depending on the disposition of the socket requires the fd to be valid when the syscall is performed. If we've already destroyed the handle (which we do by default for errors) the fd is probably invalid. On the other hand, having the fd is very important for logging especially if you hit the scenario where you have a hung process or similar, being able to correlate lsof results with what you were able to have access to in process is important. Which is why the fact that we've gone to lengths to hide the literal fd is ridiculous, especially since it does have a useful concept on windows. |
ok. well before we introduce a "tiny performance hit" I'd definitely like to review it. Per the usual. ;-) |
Ok, I've included the local port and address (where applicable)...here is the bench-net results: Master
With Changes
|
👍 |
anyone else had a chance to take a look at this? |
Can we get more people to look at this to get it pulled into master? The error messages are still the same after months and they provide very little description as to what the real error is. |
I went ahead and rebased off master again |
Thanks for all the help @evanlucas! I'm really hoping to push Node to a point where error messages are very comprehensive and are useful, because some were very confusing for me when I started, even when they shouldn't have been. Some still are complicated, and I'm hoping that merging this will get the ball rolling on revamping the current state of error messages. I think that if enough people support this, Node's developers will take a look and see how much this issue hinders beginners from using Node and how easy it is to fix compared to most of the other issues in the repository. |
👍 nice work. |
This pull request can be merged? What's the decision? |
cc @tjfontaine |
var additions = { | ||
address: address | ||
}; | ||
if (port) additions.port = port; |
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.
Doing two checks for port
. I'd change it to the following:
var additions = {
address: address
};
var details;
if (port) {
details = util.format('%s:%s', address, port);
additions.port = port;
} else {
details = address;
}
Left a few comments. Ping me back when fixed. |
Thanks! |
ping reviewers. |
req.localPort); | ||
} | ||
var ex = errnoException(status, 'connect', details, req); | ||
self._destroy(ex); |
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.
Can you go ahead and put this into
self._destroy(errnoException(status, 'connect', details, req));
No need for var ex
.
delete add[key]; | ||
} | ||
} | ||
e = add; |
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.
When _extend(e, additions)
adds object properties to e
. So add
is superfluous. Just use e
.
Few comments, other than that I'm okay with it. Though I wonder about extending this to if (isNullOrUndefined(val) || isFunction(val)) to if (isNullOrUndefined(val) || !isPrimitive(val)) I'd like to see if this might work, and then try extending it to the |
@trevnorris thanks for your time on reviewing this. I went ahead and made the requested changes. I would love to help in any way on this. Should I go ahead and take a stab at doing this for |
i--; | ||
} | ||
} | ||
exports._extend(e, additions); |
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.
Actually, screw using _extend()
. Let's just do this manually:
if (additions && isObject(additions)) {
var keys = Object.keys(additions);
for (var i = 0; i < keys.length; i++)
if (!isNullOrUndefined(keys[i]) && isPrimitive(keys[i]))
e[i] = keys[i];
}
There, much simpler.
I use isPrimitive()
because I assume no objects would be attached to the error. Would they?
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.
That makes sense to me. I'll get this changed
@evanlucas One more revision on something I already commented on. Sorry for not seeing that the first round. If you wouldn't mind doing this on Now, I would like it if the |
I think for most cases, yes. Should we just continue using the |
@evanlucas Just curious, do you have an example of when the |
@evanlucas Thanks. Let's make those cases the exception, and pass the |
Ok, |
@@ -742,7 +742,8 @@ function afterWrite(status, handle, req, err) { | |||
} | |||
|
|||
if (status < 0) { | |||
var ex = errnoException(status, 'write', err); | |||
err = util.format('%s %s:%s', err || '', req.address, req.port); |
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.
I'm curious why the err || ''
. If status < 0
then we should have an error object. Otherwise Node had a bug.
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.
Hm, I feel like there was a previous test that was failing without that, but after looking like it, doesn't appear to be true.
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.
Let's go ahead and remove it for now.
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.
will do
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.
ah found it. When passing an err
to uv.errname
, if the err if ENOTFOUND
, I get this:
util.js:739
var errname = uv.errname(err);
^
Error: err >= 0
at Error (native)
at exports._errnoException (util.js:739:20)
at net.js:941:18
at Object.asyncCallback [as callback] (dns.js:78:16)
at Object.onlookup [as oncomplete] (dns.js:91:17)
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.
Nice. Thanks for the info.
Few more comments, but looking great. Thanks for all your work here. |
Thanks! I'm happy to be able to contribute! |
Remember that |
Any update? @evanlucas |
Closing as this landed in io.js a while back |
Add address and/or port to errors where applicable for better reporting.
See #7005