Skip to content

docs: improve connect option documentation in Client.md#5344

Open
AliMahmoudDev wants to merge 1 commit into
nodejs:mainfrom
AliMahmoudDev:docs/improve-connect-option-docs
Open

docs: improve connect option documentation in Client.md#5344
AliMahmoudDev wants to merge 1 commit into
nodejs:mainfrom
AliMahmoudDev:docs/improve-connect-option-docs

Conversation

@AliMahmoudDev
Copy link
Copy Markdown

Summary

Improves the connect option documentation in Client.md to address the lack of description for one of the most important configuration options.

Problem

The connect option in ClientOptions was documented as:

* **connect** `ConnectOptions | Function | null` (optional) - Default: `null`.

This had no description at all — just a type signature and default value. Users had no guidance on:

  • What the object form does (options forwarded to buildConnector())
  • What the function form does (custom connector)
  • What arguments the function receives (hostname, host, protocol, port, servername, localAddress, httpSocket)
  • That undici wraps custom functions to inject socketPath and allowH2
  • How to use common patterns like TLS customization or Unix socket connections

Changes

  1. Added description for connect parameter (lines 30-32):

    • Explains both the object form (ConnectOptions → forwarded to buildConnector()) and function form (custom connector)
    • Documents the function signature: (options, callback) where options contains { hostname, host, protocol, port, servername, localAddress, httpSocket } and callback follows (error, socket)
    • Documents the wrapping behavior: undici injects socketPath and allowH2 into options when a function is provided
    • Cross-references buildConnector() and ConnectOptions
  2. Added example: Connect with TLS options (object form) — shows passing rejectUnauthorized and ca as a ConnectOptions object

  3. Added example: Connect via Unix domain socket — shows using socketPath for IPC connections (e.g., Docker socket)

  4. Improved custom connector example — renamed from "Custom connector" to "Custom connector (function form)", added a note callout explaining the wrapping behavior, and added a cross-reference to Connector.md

Files changed

  • docs/docs/api/Client.md

Partially addresses #886

- Add description for connect option explaining both object and function forms
- Document the function signature (options, callback) with fields
- Document the wrapping behavior (socketPath/allowH2 injection)
- Add example: Connect with TLS options (object form)
- Add example: Connect via Unix domain socket
- Improve custom connector example with note about wrapping
- Add cross-reference to Connector.md for buildConnector

Partially addresses nodejs#886
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.23%. Comparing base (ce7df65) to head (d4dd8ae).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5344      +/-   ##
==========================================
+ Coverage   93.22%   93.23%   +0.01%     
==========================================
  Files         110      110              
  Lines       36668    36668              
==========================================
+ Hits        34185    34189       +4     
+ Misses       2483     2479       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants