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

Docs imply that http globalAgent is created with keepAlive: false #48821

Closed
janeklb opened this issue Jul 17, 2023 · 1 comment · Fixed by #52392
Closed

Docs imply that http globalAgent is created with keepAlive: false #48821

janeklb opened this issue Jul 17, 2023 · 1 comment · Fixed by #52392
Labels
doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem.

Comments

@janeklb
Copy link

janeklb commented Jul 17, 2023

Affected URL(s)

https://nodejs.org/api/http.html#new-agentoptions

Description of the problem

The docs state:

The default http.globalAgent that is used by http.request() has all of these values set to their respective defaults.

Whereas globalAgent is built with

module.exports = {
  Agent,
  globalAgent: new Agent({ keepAlive: true, scheduling: 'lifo', timeout: 5000 }),
};

https://github.com/nodejs/node/blob/339eb10619ada1b482371ee244585de7f4a58552/lib/_http_agent.js#L552C1-L555C3

the only default there is scheduling: 'lifo'; keepAlive: true and timeout: 5000 are overrides.


(the history part of the globalAgent docs states "The agent now uses HTTP Keep-Alive by default." so that part is ok ✔️)

@janeklb janeklb added the doc Issues and PRs related to the documentations. label Jul 17, 2023
@VoltrexKeyva VoltrexKeyva added the http Issues or PRs related to the http subsystem. label Jul 18, 2023
@heysujal
Copy link

@VoltrexKeyva here is my understanding using scheduling : 'lifo' is not an override but it's not actually required because it is setting the same value again.
Also, I think we should add info only about the override for keepAlive and timeout here https://nodejs.org/api/http.html#httpglobalagent
So, we can mention something like
"Global instance of Agent which is used as the default for all HTTP client requests with the following overrides"
keepAlive : true
timeout : 5000

I would like to create a PR for this upon confirmation on above info.

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants