Skip to content

Set a default (http|https).Agent with keep-alive #37184

Closed
@mcollina

Description

@mcollina

In almost every deployment of Node.js, my first configuration is to set an Agent whenever we are doing an http call.
The overhead of creating new sockets or even TLS context is really high, and we should tend to reuse those as much as possible. This mostly impact users of fetch, which mostly run with a global polyfill and they do not want to set custom Node.js options when calling fetch itself.

Historically Node.js was limited to 4 outgoing connections. This created many issues and the default agent was removed entirely.

One of the problems of keep alive connections is that the socket might be timed out without Node.js knowing about it, resulting in a timeout error to the end user. The new scheduling: 'lifo' option greatly reduced the number of timeouts.

@nodejs/http @nodejs/tsc wdyt?

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions