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
feat: add more context for Request/Connect/DNSTimeoutErrors #109
Conversation
package.json
Outdated
@@ -48,7 +48,7 @@ | |||
"coveralls": "^2.11.4", | |||
"eslint": "^3.1.0", | |||
"istanbul": "^0.4.0", | |||
"jscs": "^3.0.0", | |||
"jscs": "^2.11.0", |
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.
jscs@3.x was hanging for some reason on OSX, and I'm not inclined to spend time trying to figure out why, since it is deprecated already.
bf0eabe
to
bbfd640
Compare
@davepacheco took a stab using the initial feedback in your issue. There are some open questions though, would appreciate your thoughts. |
lib/HttpClient.js
Outdated
// as TooManyRedirects. This has been rectified as TooManyRequests. | ||
// in the case of restify-clients, we will retain this error type given that | ||
// users can specify maximum number of redirects to follow. | ||
if (!errors.TooManyRedirectsError) { |
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.
This hasn't changed, I just moved it to the top of the file after the global requires and before function declarations. Also added a comment.
This looks great! Thanks for providing all the notes about the change. The one extra thing it would be nice to have as an informational property is the request method, since you can't get that from the fullUrl. Also: if you make a request to a DNS name that was resolved to a specific IP address, is this going to show up in fullUrl using the DNS name or the IP address? We usually find that both are pretty valuable, but the IP address is probably more valuable if we have to choose (because we can figure out what service it was part of if we have the IP, but if we have the DNS name, we can never figure out which instance it was). Related to #104: there's still the problem that this may not be a connection timeout at all, but rather a DNS timeout. I'm not sure if the name can be changed in a compatible way, but at least the message reflects what really happened here. Thanks again for doing this. It's going to be a huge help for us. |
Another thing that would be nice in the VError info is the socket's source IP and port so that we can correlate these issues with logs on the server side (even in the case of a connect timeout, because it's possible we handled this connection, only after the client gave up on it). |
bbfd640
to
f70d184
Compare
Sorry for dropping the ball on this! Circled back around and made all the proposed changes, including #111. There are now 3 errors depending on when things go awry: All errors return the following fields on the |
I forgot to add - tests won't pass here until restify/errors#86 lands, as we need to standardize on the use of VError (and |
lib/HttpClient.js
Outdated
// jscs:disable maximumLineLength | ||
var VERSION = JSON.parse(fs.readFileSync(path.join(__dirname, './../package.json'), 'utf8')).version; | ||
// jscs:enable maximumLineLength | ||
var VERSION = JSON.parse(fs.readFileSync( |
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.
you can require .json files directly:
var VERSION = require(path.join(__dirname, './../package.json')).version;
lib/helpers/errors.js
Outdated
* @function createConnectTimeoutErr | ||
* @param {Object} opts options object for a request | ||
* @param {Object} req the request object | ||
* @returns {Object} ConnectionTimeoutError |
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.
How about? @returns {verror.VError} ConnectionTimeoutError
lib/helpers/errors.js
Outdated
* @function createRequestTimeoutErr | ||
* @param {Object} opts options object for a request | ||
* @param {Object} req the request object | ||
* @returns {Object} RequestTimeoutError |
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.
How about? @returns {verror.VError} ConnectionTimeoutError
lib/helpers/errors.js
Outdated
|
||
|
||
|
||
function createTooManyRedirectsErr(opts, req) { |
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.
Missing JSDoc
* logging/visibility. | ||
* @private | ||
* @function fullRequestUrl | ||
* @param {Object} opts request options |
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.
missing JSDoc: options breakdown
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 PR, some smaller JSDoc issues
Thanks @hekike, all feedback addressed! Also updated package.json to point restify-errors at the commit needed so that tests will pass. Will point that to latest once a new version is published. |
@@ -21,7 +21,6 @@ var REST_CODES = [ | |||
{ name: 'InvalidVersionError', code: 400 }, | |||
{ name: 'MissingParameterError', code: 409 }, | |||
{ name: 'NotAuthorizedError', code: 403 }, | |||
{ name: 'PreconditionFailedError', code: 412 }, |
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.
These tests were added to ensure that changes in restify-error didn't break this repo. Since restify-errors is a breaking change, these tests had to be updated (arguably these tests should not belong in this repo, but don't recall the history here).
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.
Looks good to me!
0d1fe86
to
a26bc80
Compare
a26bc80
to
cfdc819
Compare
cfdc819
to
f66a0e7
Compare
Bunch of work to rebase master. Once tests pass, this is good to go. |
Addresses #104.
Here are example errors of both classes:
I'm looking for feedback on two items:
Do we want to attach more fields onto the verror
info
object? The full URL can be parsed by url.parse() to get any of the derived fields (hostname, path, protocol, port, etc.) but I'm happy to directly attach the results of url.parse() to theinfo
object as well.The initial feedback in connection-related errors could provide more information #104 sounded like we might want to have an underlying error which could be used as a cause for ConnectTimeout or RequestTimeout - but both of these seem pretty low level as is, so I decided to just attach the relevant metadata directly into
info
object. Would be happy to hear alternative approaches here.