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

Improve documentation for pool and maxSockets options #1250

Merged
merged 1 commit into from Nov 9, 2014

Conversation

nylen
Copy link
Member

@nylen nylen commented Nov 7, 2014

This has come up several times recently, for example #1150 and #1249.

This has come up several times recently, for example request#1150 and request#1249.
@anklos
Copy link

anklos commented Nov 8, 2014

Thanks!

I wonder is there any reason not use request.defaults() to change the actual request module?

I am asking this because I use unirest which depends on request. If I want to set maxSockets for unirest, I have to add request into package.json, make sure request is the same version used in unirest, then do unirest.request = require('request').defaults({pool:{maxSockets:100}}), rather than just do unirest.request.defaults({pool:{maxSockets:100}}).

@simov
Copy link
Member

simov commented Nov 8, 2014

@anklos why don't you just use

var special = unirest.request.defaults({pool:{maxSockets:100}});

it should be the same

@nylen
Copy link
Member Author

nylen commented Nov 8, 2014

Modifying global defaults is very bad.

I'm not familiar with unirest, but how about unirest.request = unirest.request.defaults({ ... })?

@anklos
Copy link

anklos commented Nov 9, 2014

@simov special is still request, I cannot call unirest functions on sepcial.

@nylen OK. I dont think I can do that as unirest does Unirest.request = require('request'); (https://github.com/Mashape/unirest-nodejs/blob/master/index.js#L787)
I may just submit a PR to unirest for setting maxSockets properly using defaults.

Thanks gents!

@nylen
Copy link
Member Author

nylen commented Nov 9, 2014

@anklos I still think my code above will work.

@anklos
Copy link

anklos commented Nov 9, 2014

@nylen It works if I use request functions. As I am using unirest to do http calls, how I would make use of special?

@nylen
Copy link
Member Author

nylen commented Nov 9, 2014

unirest.request = unirest.request.defaults({ ... });

@anklos
Copy link

anklos commented Nov 9, 2014

@nylen sorry confused by the other comment.

And my bad, you are right, that code should work. Thanks a lot!

@nylen
Copy link
Member Author

nylen commented Nov 9, 2014

You're welcome. Haven't seen any objections to this change, so merging.

nylen added a commit that referenced this pull request Nov 9, 2014
Improve documentation for pool and maxSockets options
@nylen nylen merged commit 9636cff into request:master Nov 9, 2014
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

3 participants