node icon indicating copy to clipboard operation
node copied to clipboard

http(s) agent docs for createConnection don't reflect reality

Open tkennedy1-godaddy opened this issue 8 months ago • 1 comments

Affected URL(s)

https://nodejs.org/docs/latest/api/http.html#agentcreateconnectionoptions-callback

Description of the problem

In http agents, the createConnection function is a direct passthrough to net.connect, which the function signature does not take, nor call a callback.

In https agents, the createConnection function has a wildly different signature, but the https docs say "it's the same as the http" agent. But again, there is no callback for this function and none is called.

tkennedy1-godaddy avatar May 02 '25 23:05 tkennedy1-godaddy

Quoting the documentation

By default, this function is the same as net.createConnection(). However, custom agents may override this method in case greater flexibility is desired.

A socket/stream can be supplied in one of two ways: by returning the socket/stream from this function, or by passing the socket/stream to callback

The callback is for custom implementations to allow asynchronous creation of the socket. See https://github.com/nodejs/node/blob/f552c86fecd6c2ba9e832ea129b731dd63abdbe2/lib/_http_agent.js#L324.

lpinca avatar May 03 '25 10:05 lpinca