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

Fixes connection pool bug #86

Merged
merged 3 commits into from
Mar 8, 2019
Merged

Fixes connection pool bug #86

merged 3 commits into from
Mar 8, 2019

Conversation

icalderontt
Copy link
Contributor

Now it makes use of a connection pool when necessary which should boost
requests speed.

Now it makes use of a connection pool when necessary which should boost
requests speed.
@icalderontt
Copy link
Contributor Author

Here's the related ticket: http://jira.touchtunes.com/browse/BMS-8

.nvmrc Outdated
@@ -0,0 +1 @@
8.15.0
Copy link
Contributor

Choose a reason for hiding this comment

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

I have philosophical reservations around checking-in developer specific environment artifacts like this .nvmrc' file. While it is not likely to cause issues, many devs use tj/n` or even Homebrew (uck...) to manage their Node versions and this file would be vestigial. It's not like checking in a VS Code prefs file... perhaps we should add the .nvmrc to the .gitignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it based on your comments. With my previous employer we always committed the .nvmrc file so that the next dev would know what version they are supposed to be running so I'm just used to committing it :D

lib/utils.js Outdated
*/
function createAgent(isSecure, options = {}) {
return new (isSecure ? https : http).Agent(options);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally looks like there there are mixed tabs and spaces in the file (see lines 23 to 26 above)...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops. Good find. I fixed it

@coveralls
Copy link

coveralls commented Mar 1, 2019

Coverage Status

Coverage increased (+0.07%) to 91.129% when pulling 6036575 on bugfix-http-request-pool into 45f60f4 on develop.

@cmerchant
Copy link
Contributor

Please make sure you guys are updating the the version in package.json file. The last PR for vnext branch did not include an update to the version.

@icalderontt icalderontt requested a review from privard March 4, 2019 15:39
lib/utils.js Outdated
* subsequent calls to the methods so that the same agents are reused for
* all requests
*/
module.exports.getHTTPAgent = (function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

This file seems to export only one thing, so why not call it getHTTPAgent.js instead of utils.js? Or even, connectionPool.js, or agentManager.js or something more scoped to its actual functionality?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense man. I just some changes I made based on your comment

Added all the relevant code to the http-agent.js file and also updated
the unit tests for this module.
Copy link
Contributor

@privard privard left a comment

Choose a reason for hiding this comment

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

The refactoring looks great. Before I approve, I think we need to check into how this is going to scale. I'm wondering how many connections a single agent can make, how how many requests per sec it can make on a single connection. We should definitely find a way to get numbers on this before we move this fix to production.

@privard privard self-requested a review March 6, 2019 14:59
@privard privard self-requested a review March 6, 2019 15:00
@icalderontt
Copy link
Contributor Author

@privard: that a very valid concern. I couldn't find anything online regarding reusing agents and scaling problems. One thing that we could do if we found any issues is set the max number of allowed sockets in the agent to a # higher than 32. But I think that we should heavily test in dev first

@privard
Copy link
Contributor

privard commented Mar 8, 2019

Sounds good, merge at will

@icalderontt icalderontt merged commit b86b6f1 into develop Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants