Repository navigation
fix(gaxios): forward https.Agent TLS options and agent factories in Bun - #9774
danieljbruce wants to merge 1 commit into
Conversation
|
/gemini review |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
d3f1faa to
6d4fcaa
Compare
…9773) ## Description Enforces `maxContentLength` on headerless buffered responses under Bun. ## Impact Prevents oversized buffered responses from bypassing `maxContentLength` limits on Bun. ## Changes - Enforce `maxSize` (`rawInit.size` / `rawInit.maxContentLength`) inside `readBuffer()` in `Gaxios.#createBunFetch()` so buffered (`json`, `text`, `arraybuffer`, `blob`) responses reject with `content size at <url> over limit: <maxSize>` when exceeded even without a `Content-Length` header. ### Stack 1. **#9773** — `fix(gaxios): enforce maxContentLength on headerless responses in Bun` (`fix/gaxios-bun-max-content-length` → `main`) *(this PR)* 2. #9777 — `fix(gaxios): enforce maxContentLength on stream responses in Bun` (`fix/gaxios-bun-max-content-length-stream` → `fix/gaxios-bun-max-content-length`) 3. #9778 — `fix(gaxios): honor maxContentLength and maxRedirects instance defaults` (`fix/gaxios-instance-defaults` → `fix/gaxios-bun-max-content-length-stream`) 4. #9774 — `fix(gaxios): forward https.Agent TLS options and agent factories in Bun` (`fix/gaxios-bun-agent-tls` → `fix/gaxios-instance-defaults`) ## Testing - Added unit tests in `core/packages/gaxios/test/test.getch.ts` covering `maxContentLength` rejection on headerless responses across `json`, `text`, `arraybuffer`, and `blob` response types. - **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 "maxContentLength"`. ## Alternatives - Checking `maxContentLength` only when a `Content-Length` header is present in `getResponseData()` was rejected because chunked/headerless responses silently bypass response size limits under Bun. - Not merging this PR was rejected because `node-fetch` enforces `size` on headerless responses on Node.js.
Description
Forwards
https.AgentTLS options and resolves agent factory functions under Bun.Impact
Restores custom CA, passphrase,
rejectUnauthorized, and agent factory parity on Bun.Changes
rawInit.agentinGaxios.#createBunFetch()when passed as a factory function(parsedUrl: URL) => Agent.cert,key,ca,passphrase, andrejectUnauthorizedfrom bothconnectOpts(HttpsProxyAgent) andoptions(https.Agent) intorawInit.tls.Stack
fix(gaxios): enforce maxContentLength on headerless responses in Bun(fix/gaxios-bun-max-content-length→main)fix(gaxios): enforce maxContentLength on stream responses in Bun(fix/gaxios-bun-max-content-length-stream→fix/gaxios-bun-max-content-length)fix(gaxios): honor maxContentLength and maxRedirects instance defaults(fix/gaxios-instance-defaults→fix/gaxios-bun-max-content-length-stream)fix(gaxios): forward https.Agent TLS options and agent factories in Bun(fix/gaxios-bun-agent-tls→fix/gaxios-instance-defaults) (this PR)Testing
core/packages/gaxios/test/test.getch.tsverifyinghttps.AgentTLS options (cert,key,ca,passphrase,rejectUnauthorized) and(parsedUrl: URL) => Agentfactory functions inGaxios.#createBunFetch().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
HttpsProxyAgent(connectOpts.cert/connectOpts.key) was rejected because directnew https.Agent({...})instances and(url) => Agentfactories are standardgaxiosconfigurations supported on Node.js.https.AgentTLS settings (ca,passphrase,rejectUnauthorized) are silently dropped under Bun.