FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

doc && http: fix agent default value for `keepAlive` by zckrs · Pull Request #51115 · nodejs/node · GitHub

/ node Public

doc && http: fix agent default value for keepAlive - #51115

Closed
zckrs wants to merge 2 commits into
nodejs:mainfrom
zckrs:patch-1
Closed

doc && http: fix agent default value for keepAlive#51115
zckrs wants to merge 2 commits into
nodejs:mainfrom
zckrs:patch-1

Conversation

zckrs commented Dec 11, 2023

Copy link
Copy Markdown

Since node 19, option keepAlive is true by default.

Since node 19, option keepAlive is true by default.

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

nodejs-github-bot added doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem. labels Dec 11, 2023
lpinca previously requested changes Dec 13, 2023
Comment thread doc/api/http.md
header is explicitly specified or when the `keepAlive` and `maxSockets`
options are respectively set to `false` and `Infinity`, in which case
`Connection: close` will be used. **Default:** `false`.
`Connection: close` will be used. **Default:** `true`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

this.keepAlive = this.options.keepAlive || false;

The default value is false.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🤔

So a another line in doc is misleading.

https://github.com/nodejs/node/pull/51115/files#diff-d692ac4524379ec6a1201165e8ff8d3267c8130e07014e8221ebf7e6f80c6641R183-R184

Because

globalAgent: new Agent({ keepAlive: true, scheduling: 'lifo', timeout: 5000 }),

I understand the default value for a new Agent is falsy keepAlive, but the "default" globalAgent is set to true.

~ » nvm use system
Now using system version of node: v20.10.0 (npm v10.2.5)
--------------------------------------------------------------------------------------------------
~ » node -pe 'const {keepAlive, keepAliveMsecs} = http.globalAgent; ({keepAlive, keepAliveMsecs})'
{ keepAlive: true, keepAliveMsecs: 1000 }
~ » nvm use 18
Now using node v18.19.0 (npm v10.2.3)
--------------------------------------------------------------------------------------------------
~ » node -pe 'const {keepAlive, keepAliveMsecs} = http.globalAgent; ({keepAlive, keepAliveMsecs})'
{ keepAlive: false, keepAliveMsecs: 1000 }

To be complete, in our organization (https://www.radiofrance.fr/) we had some surprises with this change in our kubernetes infrastructure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, you are right: the misleading line is the one you linked above. In #43522 I changed some options for the default agent (while leaving the constructor behavior untouched).
Could you please update this PR to fix that offending line instead of the one you proposed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done. I hope my changes are what you expect.

zckrs changed the title doc: fix agent default value for keepAlive doc && http: fix agent default value for keepAlive Dec 14, 2023
lpinca added the semver-major PRs that contain breaking changes and should be released in the next major version. label Dec 14, 2023

lpinca commented Dec 14, 2023
edited
Loading

Copy link
Copy Markdown
Member

I don't think we should change the default value in the constructor. The global agent has uses a different value and that's ok. Anyway this PR is correct now so I'm dropping my request for changes.

lpinca dismissed their stale review December 14, 2023 20:50

Changes are correct now

Copy link
Copy Markdown
Member

Why is this semver-major?

lpinca commented Dec 18, 2023
edited
Loading

Copy link
Copy Markdown
Member

Why is this semver-major?

It changes the default value of the keepAlive option in the http.Agent constructor from false to true.

Copy link
Copy Markdown
Contributor

I agree, if we want the PR this way. But I don't think we want to flip the value on the code, just in the docs for the default agent (note: not the constructor, the default instance).

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL