Conversation
Pull Request Test Coverage Report for Build 145
💛 - Coveralls |
0fbb588 to
d17e94e
Compare
| let remaining = TRIES; | ||
|
|
||
| function dnsLookupWrapperResponse (error, address, family) { | ||
| if (error && error.code === dns.NOTFOUND && --remaining > 0) { |
There was a problem hiding this comment.
It looks like some of this is implementing retry logic instead of using an existing library. Is there a reason to avoid some of the retry libraries we've used before?
There was a problem hiding this comment.
My thinking was twofold. First, using a promise-based library makes it a little more difficult/clunky to maintain the Node API interface. Second, using a dependency for a utility in an injected header like this could significantly increase the footprint of this change.
There was a problem hiding this comment.
If it was me, I'd probably use an external library for the retry logic based on callbacks. I think I understand your points and I can appreciate the trade-offs. I'll approve with the code as is it.
| assert.equal(hostname, '127.0.0.1'); | ||
| assert.equal(family, 4); | ||
| sinon.assert.callCount(lookup, 3); | ||
| callback(null, 'success!'); |
There was a problem hiding this comment.
Minor point, but a pattern I've used for callbacks in try/catch blocks is:
try {
something
} catch (e) {
callback(e);
return;
}
callback(null, success)
The current code can cause a double callback if the callback(null, 'success!'); line throws an Error. That case becomes very hard to debug when it happens.
There was a problem hiding this comment.
Good point. I'll update this. Thanks.
| const dns = require('dns'); | ||
| const lookup = dns.lookup; | ||
|
|
||
| const DELAY = 1000; |
There was a problem hiding this comment.
In the context of most requests, this seems like a very long time to wait to retry a dns lookup. Should this be a smaller value, or perhaps configurable?
There was a problem hiding this comment.
I considered this. The thing is that ENI cold starts are quite slow so I don't expect that retrying more frequently is very likely to succeed. I'd rather not make this configurable as I think it adds undo complexity and I don't see any value in changing this parameter between projects.
d17e94e to
a6cc414
Compare
No description provided.