Skip to content

Commit

Permalink
doc: call out http(s).globalAgent default
Browse files Browse the repository at this point in the history
Despite the `http.Agent` stating:

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

this isn't true anymore since node.js 19. Both, the http as well as the
https `globalAgent` now set `{ keepAlive: true, scheduling: 'lifo',
timeout: 5000 }` as options. `'lifo'` is the default anyway, but
`keepAlive` is turned off and no `timeout` is set on `new Agent()`.

Document the diverging behaviour in the `globalAgent` sections, remove
the false statement from `http.Agent` section, and extend the changelog
to call out the timeout change as well.

PR-URL: #52392
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Ulises Gascón <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
  • Loading branch information
fahrradflucht authored Apr 8, 2024
1 parent db17461 commit 655b327
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ changes:

`options` in [`socket.connect()`][] are also supported.

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

To configure any of them, a custom [`http.Agent`][] instance must be created.

```mjs
Expand Down Expand Up @@ -3654,13 +3651,15 @@ changes:
- version:
- v19.0.0
pr-url: https://github.com/nodejs/node/pull/43522
description: The agent now uses HTTP Keep-Alive by default.
description: The agent now uses HTTP Keep-Alive and a 5 second timeout by
default.
-->

* {http.Agent}

Global instance of `Agent` which is used as the default for all HTTP client
requests.
requests. Diverges from a default `Agent` configuration by having `keepAlive`
enabled and a `timeout` of 5 seconds.

## `http.maxHeaderSize`

Expand Down
7 changes: 5 additions & 2 deletions doc/api/https.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,13 @@ changes:
- version:
- v19.0.0
pr-url: https://github.com/nodejs/node/pull/43522
description: The agent now uses HTTP Keep-Alive by default.
description: The agent now uses HTTP Keep-Alive and a 5 second timeout by
default.
-->

Global instance of [`https.Agent`][] for all HTTPS client requests.
Global instance of [`https.Agent`][] for all HTTPS client requests. Diverges
from a default [`https.Agent`][] configuration by having `keepAlive` enabled and
a `timeout` of 5 seconds.

## `https.request(options[, callback])`

Expand Down

0 comments on commit 655b327

Please sign in to comment.