-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Avoid inadvertently invoking unwrapped request in vendor helper functions #924
Conversation
- Tweak a couple names to improve readability
Let me take a moment to explain these changes. The It's 100+ lines, with no tests or doc, so it's difficult to read and reason about. The first thing I tried was finding where its argument was used, which was difficult because it was named All the vendor badges invoke |
server.js
Outdated
@@ -177,7 +176,7 @@ vendorDomain.on('error', function(err) { | |||
}); | |||
|
|||
|
|||
function cache(f) { | |||
function cache(wrappedFn) { |
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's a clearer name. We can probably make it clearer still. What do you think about vendorProcessing
?
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'd be good with vendorProcessingFn
.
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.
Or vendorRequestHandler
.
@@ -236,7 +235,8 @@ function cache(f) { | |||
|
|||
// Only call vendor servers when last request is older than… | |||
var cacheInterval = 5000; // milliseconds | |||
var cachedRequest = function (uri, options, callback) { | |||
var cachingRequest = function (uri, options, callback) { | |||
var request = require('request'); |
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 do you want to require request every time we need it, instead of once and for all?
If you're worried about mistakenly calling it, we can change its name to httpRequest
or something like that.
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 only use it twice. It seems clearer to require it both times than introduce a new name. I don't feel that strongly though.
# Conflicts: # server.js
Tested locally by manually checking teamcity, and running my experimental recorded tests which cover travis.