Skip to content

doc: improve agent.createConnection docs for http and https agents #58205

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mag123c
Copy link

@mag123c mag123c commented May 7, 2025

This PR improves the documentation for http.Agent#createConnection() and https.Agent by clarifying the behavior of the createConnection(options[, callback]) method.

In the current docs, the callback is mentioned but not explained clearly in the context of default vs. custom agent implementations. This has led to confusion, especially when overriding the method for asynchronous socket creation.

The updated docs now state:

The default implementation does not use the callback and returns the socket synchronously.

Custom agents may override createConnection to support asynchronous connection creation using a (err, socket) style callback.

For https.Agent, a note was added that its createConnection method uses tls.connect() internally and follows the same override pattern as http.Agent.

This change resolves issue #58131.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label May 7, 2025
@mag123c mag123c force-pushed the docs/agent-createconnection-callback-clarification branch from e99a2ca to add0b05 Compare May 8, 2025 15:27
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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