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

fix: maxSockets Infinity value may set to null sometimes #938

Merged
merged 2 commits into from
May 27, 2017

Conversation

coolme200
Copy link
Contributor

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

@codecov
Copy link

codecov bot commented May 19, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@5b6fe2b). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##             master   #938   +/-   ##
=======================================
  Coverage          ?   100%           
=======================================
  Files             ?     28           
  Lines             ?    670           
  Branches          ?      0           
=======================================
  Hits              ?    670           
  Misses            ?      0           
  Partials          ?      0
Impacted Files Coverage Δ
config/config.default.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b6fe2b...16a0a86. Read the comment docs.

* @property {Number} maxFreeSockets - max free socket number of one host, default is 256.
* @property {Boolean} enableDNSCache - Enable DNS lookup from local cache or not, default is false.
*/
config.httpclient = {
keepAlive: true,
freeSocketKeepAliveTimeout: 4000,
timeout: 30000,
maxSockets: Infinity,
maxSockets: Number.MAX_VALUE,
Copy link
Member

Choose a reason for hiding this comment

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

目前还好的是 agentkeepalive 发现这个配置是 null 会默认设置为 Infinity https://github.com/node-modules/agentkeepalive/blob/master/lib/_http_agent.js#L63

Copy link
Member

Choose a reason for hiding this comment

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

加个用例吧

* @property {Number} maxFreeSockets - max free socket number of one host, default is 256.
* @property {Boolean} enableDNSCache - Enable DNS lookup from local cache or not, default is false.
*/
config.httpclient = {
keepAlive: true,
freeSocketKeepAliveTimeout: 4000,
timeout: 30000,
maxSockets: Infinity,
maxSockets: Number.MAX_VALUE,
Copy link
Member

Choose a reason for hiding this comment

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

加个用例吧

Copy link
Contributor

@iyuq iyuq left a comment

Choose a reason for hiding this comment

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

Use Number. MAX_SAFE_INTEGER will be better.

* @property {Number} maxFreeSockets - max free socket number of one host, default is 256.
* @property {Boolean} enableDNSCache - Enable DNS lookup from local cache or not, default is false.
*/
config.httpclient = {
keepAlive: true,
freeSocketKeepAliveTimeout: 4000,
timeout: 30000,
maxSockets: Infinity,
maxSockets: utility.MAX_SAFE_INTEGER,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the more proper way is to use Number. MAX_SAFE_INTEGER instead of utility.MAX_SAFE_INTEGER. We only support node.js >= 6.0, so the Number.MAX_SAFE_INTEGER is always available.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, @coolme200 Please use Number.MAX_SAFE_INTEGER instead.

// 允许创建的最大 socket 数
maxSockets: Infinity,
// 允许创建的最大 socket 数 https://github.com/node-modules/utility/blob/master/lib/number.js#L5
maxSockets: utility.MAX_SAFE_INTEGER,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@fengmk2
Copy link
Member

fengmk2 commented May 27, 2017

@coolme200 我来改改手动合并。

@fengmk2 fengmk2 merged commit 35fa5a9 into master May 27, 2017
@fengmk2 fengmk2 deleted the fix-maxSockets branch May 27, 2017 10:36
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.

4 participants