Skip to content

fix(gaxios): forward https.Agent TLS options and agent factories in Bun - #9774

Draft
danieljbruce wants to merge 1 commit into
fix/gaxios-instance-defaultsfrom
fix/gaxios-bun-agent-tls
Draft

danieljbruce wants to merge 1 commit into
fix/gaxios-instance-defaultsfrom
fix/gaxios-bun-agent-tls

Conversation

@danieljbruce

@danieljbruce danieljbruce commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Forwards https.Agent TLS options and resolves agent factory functions under Bun.

Impact

Restores custom CA, passphrase, rejectUnauthorized, and agent factory parity on Bun.

Changes

  • Resolve rawInit.agent in Gaxios.#createBunFetch() when passed as a factory function (parsedUrl: URL) => Agent.
  • Forward cert, key, ca, passphrase, and rejectUnauthorized from both connectOpts (HttpsProxyAgent) and options (https.Agent) into rawInit.tls.

Stack

  1. fix(gaxios): enforce maxContentLength on headerless responses in Bun #9773 — fix(gaxios): enforce maxContentLength on headerless responses in Bun (fix/gaxios-bun-max-content-length → main)
  2. fix(gaxios): enforce maxContentLength on stream responses in Bun #9777 — fix(gaxios): enforce maxContentLength on stream responses in Bun (fix/gaxios-bun-max-content-length-stream → fix/gaxios-bun-max-content-length)
  3. fix(gaxios): honor maxContentLength and maxRedirects instance defaults #9778 — fix(gaxios): honor maxContentLength and maxRedirects instance defaults (fix/gaxios-instance-defaults → fix/gaxios-bun-max-content-length-stream)
  4. fix(gaxios): forward https.Agent TLS options and agent factories in Bun #9774 — fix(gaxios): forward https.Agent TLS options and agent factories in Bun (fix/gaxios-bun-agent-tls → fix/gaxios-instance-defaults) (this PR)

Testing

  • Added unit tests in core/packages/gaxios/test/test.getch.ts verifying https.Agent TLS options (cert, key, ca, passphrase, rejectUnauthorized) and (parsedUrl: URL) => Agent factory functions in Gaxios.#createBunFetch().
  • Steps to Reproduce (in terminal): Run cd core/packages/gaxios && pnpm run compile && JS_RUNTIME=bun MOCHA_PARALLEL=false bun --bun ../../../bin/run-test.cjs --no-c8 build/esm/test/test.getch.js -g "pass proxy and tls options".

Alternatives

  • Supporting only HttpsProxyAgent (connectOpts.cert / connectOpts.key) was rejected because direct new https.Agent({...}) instances and (url) => Agent factories are standard gaxios configurations supported on Node.js.
  • Not merging this PR was rejected because custom https.Agent TLS settings (ca, passphrase, rejectUnauthorized) are silently dropped under Bun.

@danieljbruce

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the Bun fetch implementation in Gaxios to support more flexible agent configurations, including agent factory functions and extracting additional TLS options such as ca, passphrase, and rejectUnauthorized from the agent's options or connection options. Corresponding unit tests have been added to verify that these options are correctly mapped to the tls configuration. I have no feedback to provide.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the Bun fetch implementation in Gaxios by adding support for custom HTTPS agents and agent factory functions. It correctly extracts TLS options such as cert, key, ca, passphrase, and rejectUnauthorized from the agent's options or connection options and maps them to the TLS configuration. Corresponding unit tests have been added to verify this behavior. There are no review comments, and I have no additional feedback to provide.

@danieljbruce
danieljbruce force-pushed the fix/gaxios-bun-agent-tls branch from d3f1faa to 6d4fcaa Compare October 29, 2026 15:59
@danieljbruce
danieljbruce changed the base branch from fix/gaxios-bun-max-content-length to fix/gaxios-instance-defaults October 29, 2026 16:01
@danieljbruce
danieljbruce added this pull request to stack #9782 October 29, 2026 20:51

This branch has not been deployed

No deployments
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.

1 participant