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

"forever" option is useless in node 0.12.* #1709

Closed
calibr opened this issue Jul 31, 2015 · 1 comment
Closed

"forever" option is useless in node 0.12.* #1709

calibr opened this issue Jul 31, 2015 · 1 comment

Comments

@calibr
Copy link
Contributor

calibr commented Jul 31, 2015

because it's creates new agents every request, for example:

var request = Request.forever({
  maxSockets: 2
});

var r1 = request("http://google.com", function() {});
var r2 = request("http://google.com", function() {});

console.log(r1.agent === r2.agent); //prints false, but should be true

Problem is here https://github.com/request/request/blob/master/request.js#L486 .

This can be fixed by replacing this line by something like this:

self.agentClass = self.httpModule.Agent;
self.agentOptions.keepAlive = true;

Such behaviour makes sockets not reusable, because creates new pool(agent) every http request.

@simov
Copy link
Member

simov commented Aug 1, 2015

Generally speaking the forever option should not be used in anything higher than node 0.10 (as stated in the docs), see #1671 for details. Your fix proposal looks good 👍

calibr pushed a commit to calibr/request that referenced this issue Aug 4, 2015
calibr pushed a commit to calibr/request that referenced this issue Aug 5, 2015
simov added a commit that referenced this issue Aug 10, 2015
Fix forever option in node > 0.10 #1709
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

No branches or pull requests

2 participants