Skip to content

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Dec 8, 2025

Summary by CodeRabbit

  • New Features

    • Added TypeScript declarations for FormStream methods (headers, file, field).
  • Chores

    • Enforced pnpm@10.24.0 and started versioning pnpm-lock.yaml.
    • Added formatting/typecheck scripts (fmt, fmtcheck, typecheck) and oxfmt dev dependency.
    • CI/workflow and formatter configuration updated for consistent formatting and quality checks.
  • Documentation

    • README formatting updated for improved argument styling.

✏️ Tip: You can customize this high-level summary in your review settings.

@fengmk2 fengmk2 requested a review from Copilot December 8, 2025 14:02
@coderabbitai
Copy link

coderabbitai bot commented Dec 8, 2025

Warning

Rate limit exceeded

@fengmk2 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 53 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 753db48 and f4f4e16.

📒 Files selected for processing (6)
  • .github/workflows/nodejs-16.yml (1 hunks)
  • .github/workflows/nodejs.yml (1 hunks)
  • test/HttpClient.test.ts (10 hunks)
  • test/diagnostics_channel.test.ts (4 hunks)
  • test/options.timeout.test.ts (3 hunks)
  • test/urllib.options.rejectUnauthorized-false.test.ts (2 hunks)

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Repository-wide formatting, CI, and tooling updates plus small API typing and one-loop behavior change: CI workflow normalization and a new typecheck job, oxfmt config and scripts added, pnpm lockfile now versioned, many import/format adjustments, one early-exit break added in HttpAgent address validation, and three FormStream d.ts methods added.

Changes

Cohort / File(s) Summary
CI workflows
\.github/workflows/nodejs-16.yml, \.github/workflows/nodejs.yml, \.github/workflows/release.yml
Normalized branch array formatting ([ master ][master]); added/renamed typecheck job in nodejs.yml with checkout, pnpm, node setup, install, lint/dedupe/typecheck/fmt/build steps; minor whitespace edits.
Formatting & tooling config
\.oxfmtrc.json (new), \.oxlintrc.json, renovate.json, tsconfig.json, vite.config.ts
Added oxfmt config; normalized JSON/array formatting, trailing commas/newlines, and import/order formatting.
Package & lockfile
package.json, \.gitignore
Added packageManager: "pnpm@10.24.0", new scripts fmt, typecheck, fmtcheck, added oxfmt devDependency; removed pnpm-lock.yaml from .gitignore so lockfile is tracked.
Type declarations added
src/formstream.d.ts
Added instance methods to FormStream typings: headers(): Record<string,string>, file(name:string,path:string): void, field(name:string,value:string): void.
Behavioral change
src/HttpAgent.ts
Added break in address-validation loop to exit on first invalid address (early exit). Also import/type punctuation normalization.
Source formatting & imports
src/*.ts (e.g., src/BaseAgent.ts, src/HttpClient.ts, src/HttpClientError.ts, src/IncomingHttpHeaders.ts, src/Request.ts, src/Response.ts, src/FormData.ts, src/diagnosticsChannel.ts, src/fetch.ts, src/utils.ts, src/index.ts, src/FetchOpaqueInterceptor.ts)
Reordered/consolidated imports, whitespace/type punctuation normalization (commas → semicolons in type literals), minor literal/string formatting changes; no functional change except noted HttpAgent.ts.
Examples
examples/*.cjs (e.g., examples/httpclient.cjs, examples/*h2*.cjs, examples/timing.cjs, examples/search_github.cjs, examples/longruning.cjs)
Reflowed promise chains and callbacks to multi-line formatting; no behavioral changes.
Test fixtures & tests
test/fixtures/*, test/**/*.test.*, many test/* files (large set)
Wide-ranging formatting, import reorders, explicit AddressInfo casts for port extraction, consistent arrow parameter parentheses, refactors of assert.rejects styles, and minor type/signature notation changes in fixture return types; tests preserve behavior.
Scripts
scripts/replace_urllib_version.js
Converted multi-line array to single-line, minor callback parameter formatting; no behavioral change.
Documentation
README.md
Markdown emphasis styling changes in Arguments section (bold → italic); no content changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

Areas requiring extra attention:

  • src/HttpAgent.ts — verify the newly added break in address validation does not hide additional invalid entries or change intended validation semantics.
  • package.json & .gitignore — confirm intent to track pnpm-lock.yaml and that pnpm version pinning is desired.
  • src/formstream.d.ts — confirm the new typings align with the runtime FormStream implementation (methods exist and signatures match).
  • A few formatting-driven type punctuation changes (commas → semicolons) across src/ and test/ files — spot-check TypeScript parsing/exports.

Possibly related PRs

Suggested reviewers

  • killagu

Poem

🐇 I hop through diffs with nimble paws,

Semicolons tamed and tidy laws.
CI paths aligned, formatters in tune,
A tiny break, a new type rune.
Hooray — the repo looks neat today! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: enable oxfmt' accurately summarizes the main change - enabling oxfmt code formatting throughout the project, evidenced by addition of .oxfmtrc.json config and extensive formatting adjustments across all files.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@socket-security
Copy link

socket-security bot commented Dec 8, 2025

@gemini-code-assist
Copy link

Summary of Changes

Hello @fengmk2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing code consistency and maintainability by integrating oxfmt, a new code formatter, into the project's development workflow. The changes include adding oxfmt configuration, updating package.json scripts to incorporate formatting and type-checking commands, and applying oxfmt's stylistic rules across the entire codebase. This initiative aims to standardize the code style, making it easier for developers to read and contribute to the project.

Highlights

  • Introduction of oxfmt: A new code formatter, oxfmt, has been integrated into the project, with its configuration defined in .oxfmtrc.json.
  • Updated Development Scripts: New npm scripts (fmt, typecheck, fmtcheck) have been added to facilitate oxfmt usage and type checking. The ci script was adjusted to remove explicit linting, likely deferring formatting checks to oxfmt.
  • Codebase Reformatting: Extensive formatting changes have been applied across various files, including source code, examples, and test files, to adhere to the new oxfmt style. This includes import reordering, line wrapping adjustments, and minor syntax cleanups.
  • Dependency Updates: oxfmt has been added as a development dependency in package.json.
Ignored Files
  • Ignored by pattern: .github/workflows/** (3)
    • .github/workflows/nodejs-16.yml
    • .github/workflows/nodejs.yml
    • .github/workflows/release.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables oxfmt as the code formatter for the project, applying consistent formatting across all TypeScript, JavaScript, JSON, and Markdown files. The changes include configuration setup, CI integration, and automatic formatting of the entire codebase.

  • New formatter configuration with 120 character line width, single quotes, and automatic import sorting
  • CI workflow updated to enforce formatting checks on all pull requests
  • Package manager explicitly set to pnpm@10.24.0 with lock file management changes

Reviewed changes

Copilot reviewed 78 out of 82 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.oxfmtrc.json New formatter configuration with import sorting and style rules
package.json Added oxfmt dependency, format scripts, and packageManager field; removed lint from CI script
.github/workflows/nodejs.yml Added dedicated typecheck job with lint, format check, and build validation
.gitignore Removed pnpm-lock.yaml from ignore list to commit lock files
src/**/*.ts Applied formatting: import reordering, consistent spacing, line breaks, trailing commas
test/**/*.ts Applied formatting: import reordering, multi-line function calls, consistent indentation
examples/**/*.cjs Applied formatting: promise chains, arrow functions, consistent spacing
vite.config.ts, tsconfig.json, etc. Applied formatting: single-line arrays, trailing commas in objects

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 90.50279% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.93%. Comparing base (0b1e89d) to head (f4f4e16).
⚠️ Report is 21 commits behind head on master.

Files with missing lines Patch % Lines
src/utils.ts 50.00% 6 Missing and 4 partials ⚠️
src/diagnosticsChannel.ts 85.41% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #602      +/-   ##
==========================================
- Coverage   94.95%   93.93%   -1.02%     
==========================================
  Files          11       11              
  Lines        1387     1467      +80     
  Branches      316      318       +2     
==========================================
+ Hits         1317     1378      +61     
- Misses         66       85      +19     
  Partials        4        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.

Copy link

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

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 enables oxfmt and applies its formatting across the codebase. The changes are mostly stylistic and improve code consistency. I've noticed that the ci script in package.json no longer includes a linting step. I've added a comment to suggest re-adding it, along with the new format and type checking scripts, to maintain code quality in the CI pipeline. Overall, the changes look good and align with the goal of introducing a code formatter.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (10)
test/urllib.options.rejectUnauthorized-false.test.ts (1)

63-63: Resolve TypeScript error: unsafe property access on union type.

The non-null assertion ! removes null/undefined from the union but doesn't narrow string | AddressInfo. When server.address() returns a string (Unix domain socket), accessing .port fails. Use an explicit type assertion or type guard.

Apply one of these fixes:

Option 1: Type assertion (if you know it will always be AddressInfo):

-    const url = `https://localhost:${server.address()!.port}`;
+    const url = `https://localhost:${(server.address() as AddressInfo).port}`;

You'll also need to import AddressInfo:

-import { createSecureServer } from 'node:http2';
+import { createSecureServer } from 'node:http2';
+import type { AddressInfo } from 'node:net';

Option 2: Type guard (safer):

+    const address = server.address();
+    if (typeof address === 'string') {
+      throw new Error('Server listening on Unix socket, expected TCP address');
+    }
-    const url = `https://localhost:${server.address()!.port}`;
+    const url = `https://localhost:${address.port}`;
test/fixtures/socket_server.ts (1)

15-15: Remove unused parameter or prefix with underscore.

The TypeScript compiler reports that the req parameter is declared but never used. Consider either using the parameter or prefixing it with an underscore (_req) to indicate it's intentionally unused.

Apply this diff to fix the issue:

-  unixSocketServer.on('request', (req, res) => {
+  unixSocketServer.on('request', (_req, res) => {
test/options.timeout.test.ts (1)

84-116: Fix TypeScript strict mode error on server.address().port and add missing server cleanup

The non-null assertion ! on server.address() is insufficient in strict mode. Since server.address() returns string | AddressInfo | null, and string (unix domain sockets) has no .port property, TypeScript will fail the typecheck. Additionally, the server resource is not closed after the test, which can leave connections open.

Apply this fix:

-import { createSecureServer } from 'node:http2';
+import type { AddressInfo } from 'node:net';
+import { createSecureServer } from 'node:http2';
@@
-    const url = `https://localhost:${server.address()!.port}`;
+    const { port } = server.address() as AddressInfo;
+    const url = `https://localhost:${port}`;
     await assert.rejects(
       async () => {
         await httpClient.request(url, {
           timeout: 10,
         });
       },
       (err: any) => {
         // console.error(err);
         assert.equal(err.name, 'HttpClientRequestTimeoutError');
         assert.equal(err.message, 'Request timeout for 10 ms');
         assert.equal(err.cause.name, 'InformationalError');
         assert.equal(err.cause.message, 'HTTP/2: "stream timeout after 10"');
         assert.equal(err.cause.code, 'UND_ERR_INFO');

         assert.equal(err.res.status, -1);
         assert(err.res.rt > 10, `actual ${err.res.rt}`);
         assert.equal(typeof err.res.rt, 'number');
         return true;
       },
     );
+    server.close();
+    await once(server, 'close');

The type assertion as AddressInfo is required for strict TypeScript checking since the server is listening on TCP (port 0). Closing the server after the test prevents resource leaks and matches the cleanup pattern used elsewhere in the test suite.

test/HttpClient.test.ts (3)

160-160: Fix TypeScript error: Handle null case for server.address().

The pipeline reports that server.address() can return string | AddressInfo | null, but the code accesses .port without null checking.

Apply this diff to fix the type safety issue:

-      const url = `https://localhost:${server.address()!.port}`;
+      const address = server.address();
+      if (!address || typeof address === 'string') {
+        throw new Error('Failed to get server address');
+      }
+      const url = `https://localhost:${address.port}`;

223-223: Fix TypeScript error: Handle null case for server.address().

Same issue as Line 160 - server.address() requires null and type checking.

Apply this diff:

-      const url = `https://localhost:${server.address()!.port}`;
+      const address = server.address();
+      if (!address || typeof address === 'string') {
+        throw new Error('Failed to get server address');
+      }
+      const url = `https://localhost:${address.port}`;

414-416: Remove unused parameter.

The address parameter is declared but never used, triggering a TypeScript warning.

Apply this diff:

-        checkAddress(address, family) {
+        checkAddress(_address, family) {
           return family !== 6;
         },
test/diagnostics_channel.test.ts (1)

220-220: Fix TypeScript error: Handle null case for server.address().

The pipeline reports two errors:

  1. server.address() can return null
  2. It can return string | AddressInfo, but the code assumes AddressInfo with a port property

Apply this diff to fix the type safety issues:

-    _url = `https://localhost:${server.address().port}`;
+    const address = server.address();
+    if (!address || typeof address === 'string') {
+      throw new Error('Failed to get server address');
+    }
+    _url = `https://localhost:${address.port}`;
src/diagnosticsChannel.ts (1)

34-54: Fix local symbols shadowing the imported symbols module in formatSocket.

Inside formatSocket, the local const symbols = Object.getOwnPropertySymbols(socket); shadows the imported symbols module. As a result, expressions like socket[symbols.kSocketLocalAddress] use the local symbol[] instead of the symbol constants module, so localAddress / localPort will always resolve via socket[undefined] and stay undefined in logs.

Renaming the local variable avoids the shadowing and restores correct logging of symbol-backed properties:

 function formatSocket(socket: SocketExtend) {
   if (!socket) return socket;
   if (!kSocketReset) {
-    const symbols = Object.getOwnPropertySymbols(socket);
-    for (const symbol of symbols) {
+    const socketSymbols = Object.getOwnPropertySymbols(socket);
+    for (const symbol of socketSymbols) {
       if (symbol.description === 'reset') {
         kSocketReset = symbol;
         break;
       }
     }
   }
   return {
     localAddress: socket[symbols.kSocketLocalAddress],
     localPort: socket[symbols.kSocketLocalPort],
test/fixtures/server.ts (2)

15-32: Fix TS7053 on req.socket[requestsPerSocket] by using a typed socket alias.

The CI errors on Lines 24 and 30 come from indexing Socket with a unique symbol. A small local typing change fixes both the type error and clarifies intent:

 const requestsPerSocket = Symbol('requestsPerSocket');

 export async function startServer(options?: {
   keepAliveTimeout?: number;
   https?: boolean;
 }): Promise<{ server: Server; url: string; urlWithDns: string; closeServer: any }> {
   let server: Server;
   const requestHandler = async (req: IncomingMessage, res: ServerResponse) => {
     const startTime = Date.now();
-    req.socket[requestsPerSocket] = (req.socket[requestsPerSocket] || 0) + 1;
+    const socket = req.socket as Socket & { [requestsPerSocket]?: number };
+    socket[requestsPerSocket] = (socket[requestsPerSocket] ?? 0) + 1;
@@
-    res.setHeader('x-requests-persocket', req.socket[requestsPerSocket]);
-    res.setHeader('x-requests-socket-port', req.socket.remotePort!);
+    res.setHeader('x-requests-persocket', socket[requestsPerSocket] ?? 0);
+    res.setHeader('x-requests-socket-port', socket.remotePort!);

The connections: Socket[] = [] and server.on('connection', (connection) => { ... }) part is already correctly typed and works well with this change.

Also applies to: 432-459


317-355: Add explicit types for result.files and result.form to resolve TS7053.

result.files[name] = ... and result.form[name] = val currently index into {}-typed objects, triggering TS7053 in strict mode. Giving result an explicit shape with string index signatures fixes both errors and documents the structure:

-      const result = {
-        method: req.method,
-        url: req.url,
-        href: urlObject.href,
-        headers: req.headers,
-        files: {},
-        form: {},
-      };
+      const result: {
+        method: string | undefined;
+        url: string | undefined;
+        href: string;
+        headers: IncomingMessage['headers'];
+        files: Record<
+          string,
+          {
+            filename: string;
+            encoding: string;
+            mimeType: string;
+            size: number;
+          }
+        >;
+        form: Record<string, any>;
+      } = {
+        method: req.method,
+        url: req.url,
+        href: urlObject.href,
+        headers: req.headers,
+        files: {},
+        form: {},
+      };
@@
-            result.files[name] = {
+            result.files[name] = {
               filename,
               encoding,
               mimeType,
               size,
             };
@@
-        result.form[name] = val;
+        result.form[name] = val;

This keeps runtime behavior identical while satisfying the compiler and making the multipart response structure explicit.

🧹 Nitpick comments (1)
src/HttpClient.ts (1)

82-87: Update checkAddress JSDoc to reflect the actual function signature.

CheckAddressFunction is defined as (ip: string, family: number | string, hostname: string) => boolean, but the comment here says it receives “two arguments (ip and family)”. Consider updating the description to mention the third hostname parameter so users don’t miss it.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00d2439 and ed6afda.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (81)
  • .github/workflows/nodejs-16.yml (2 hunks)
  • .github/workflows/nodejs.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)
  • .gitignore (0 hunks)
  • .oxfmtrc.json (1 hunks)
  • .oxlintrc.json (2 hunks)
  • README.md (1 hunks)
  • examples/h2-other-side-closed-exit-0-fetch.cjs (2 hunks)
  • examples/h2-other-side-closed-exit-0.cjs (2 hunks)
  • examples/httpclient.cjs (1 hunks)
  • examples/longruning.cjs (1 hunks)
  • examples/search_github.cjs (1 hunks)
  • examples/timing.cjs (1 hunks)
  • package.json (4 hunks)
  • renovate.json (1 hunks)
  • scripts/replace_urllib_version.js (1 hunks)
  • src/BaseAgent.ts (1 hunks)
  • src/FetchOpaqueInterceptor.ts (1 hunks)
  • src/FormData.ts (2 hunks)
  • src/HttpAgent.ts (2 hunks)
  • src/HttpClient.ts (16 hunks)
  • src/HttpClientError.ts (1 hunks)
  • src/IncomingHttpHeaders.ts (1 hunks)
  • src/Request.ts (3 hunks)
  • src/Response.ts (1 hunks)
  • src/diagnosticsChannel.ts (6 hunks)
  • src/fetch.ts (6 hunks)
  • src/index.ts (2 hunks)
  • src/utils.ts (6 hunks)
  • test/HttpClient.connect.rejectUnauthorized.test.ts (2 hunks)
  • test/HttpClient.events.test.ts (5 hunks)
  • test/HttpClient.test.ts (8 hunks)
  • test/diagnostics_channel.test.ts (3 hunks)
  • test/esm/index.js (1 hunks)
  • test/fetch-head-request-should-keepalive.test.ts (1 hunks)
  • test/fetch.test.ts (6 hunks)
  • test/fixtures/server.ts (9 hunks)
  • test/fixtures/socket_server.ts (2 hunks)
  • test/fixtures/ts-cjs-es2021/tsconfig.json (1 hunks)
  • test/fixtures/ts-esm/tsconfig.json (1 hunks)
  • test/fixtures/ts/tsconfig.json (1 hunks)
  • test/formData-with-BufferStream.test.ts (1 hunks)
  • test/head-request-should-keepalive.test.ts (1 hunks)
  • test/index.test.ts (7 hunks)
  • test/keep-alive-header.test.ts (4 hunks)
  • test/mts/src/index.mts (1 hunks)
  • test/mts/tsconfig.json (1 hunks)
  • test/non-ascii-request-header.test.ts (2 hunks)
  • test/options.auth.test.ts (1 hunks)
  • test/options.compressed.test.ts (3 hunks)
  • test/options.content.test.ts (1 hunks)
  • test/options.data.test.ts (16 hunks)
  • test/options.dataType.test.ts (3 hunks)
  • test/options.digestAuth.test.ts (1 hunks)
  • test/options.dispatcher.test.ts (3 hunks)
  • test/options.files.test.ts (8 hunks)
  • test/options.fixJSONCtlChars.test.ts (2 hunks)
  • test/options.followRedirect.test.ts (3 hunks)
  • test/options.gzip.test.ts (1 hunks)
  • test/options.headers.test.ts (1 hunks)
  • test/options.method.test.ts (1 hunks)
  • test/options.opaque.test.ts (2 hunks)
  • test/options.reset.test.ts (1 hunks)
  • test/options.retry.test.ts (1 hunks)
  • test/options.signal.test.ts (2 hunks)
  • test/options.socketErrorRetry.test.ts (3 hunks)
  • test/options.socketPath.test.ts (1 hunks)
  • test/options.stream.test.ts (3 hunks)
  • test/options.streaming.test.ts (3 hunks)
  • test/options.timeout.test.ts (3 hunks)
  • test/options.timing.test.ts (1 hunks)
  • test/options.type.test.ts (1 hunks)
  • test/options.writeStream.test.ts (3 hunks)
  • test/response-charset-gbk.test.ts (1 hunks)
  • test/urllib.options.allowH2.test.ts (1 hunks)
  • test/urllib.options.rejectUnauthorized-false.test.ts (1 hunks)
  • test/user-agent.test.ts (1 hunks)
  • test/utils.test.ts (1 hunks)
  • test/utils.ts (1 hunks)
  • tsconfig.json (1 hunks)
  • vite.config.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • .gitignore
🧰 Additional context used
🧬 Code graph analysis (17)
test/options.streaming.test.ts (3)
test/cjs/index.js (1)
  • assert (2-2)
src/utils.ts (1)
  • isReadable (153-166)
test/utils.ts (1)
  • readableToBytes (8-15)
test/HttpClient.connect.rejectUnauthorized.test.ts (1)
src/HttpClient.ts (1)
  • HttpClient (180-811)
examples/h2-other-side-closed-exit-0-fetch.cjs (1)
src/index.ts (2)
  • setGlobalDispatcher (95-95)
  • Agent (93-93)
test/options.timeout.test.ts (1)
src/HttpClientError.ts (1)
  • HttpClientRequestTimeoutError (16-23)
test/options.dataType.test.ts (1)
test/utils.ts (1)
  • nodeMajorVersion (38-40)
test/HttpClient.events.test.ts (1)
test/cjs/index.js (1)
  • assert (2-2)
src/diagnosticsChannel.ts (1)
src/utils.ts (1)
  • performanceTime (149-151)
test/keep-alive-header.test.ts (1)
test/cjs/index.js (1)
  • assert (2-2)
test/fetch.test.ts (3)
src/HttpClient.ts (2)
  • RequestDiagnosticsMessage (142-146)
  • ResponseDiagnosticsMessage (148-154)
src/index.ts (4)
  • RequestDiagnosticsMessage (111-111)
  • ResponseDiagnosticsMessage (112-112)
  • FetchFactory (130-130)
  • fetch (130-130)
src/fetch.ts (6)
  • FetchDiagnosticsMessage (47-50)
  • FetchResponseDiagnosticsMessage (52-58)
  • FetchFactory (60-297)
  • fetch (141-284)
  • fetch (294-296)
  • fetch (299-299)
examples/h2-other-side-closed-exit-0.cjs (1)
src/index.ts (2)
  • setGlobalDispatcher (95-95)
  • Agent (93-93)
src/HttpClient.ts (3)
src/HttpAgent.ts (1)
  • CheckAddressFunction (8-8)
src/Request.ts (2)
  • RequestURL (12-12)
  • RequestOptions (19-164)
src/utils.ts (2)
  • isReadable (153-166)
  • digestAuthHeader (73-137)
src/Request.ts (1)
src/index.ts (1)
  • Request (97-97)
examples/search_github.cjs (1)
examples/httpclient.cjs (1)
  • urllib (11-11)
src/fetch.ts (2)
src/HttpClient.ts (1)
  • request (242-244)
src/index.ts (1)
  • request (66-79)
test/options.compressed.test.ts (2)
test/cjs/index.js (1)
  • assert (2-2)
examples/httpclient.cjs (1)
  • urllib (11-11)
src/HttpAgent.ts (2)
src/index.ts (1)
  • CheckAddressFunction (125-125)
src/BaseAgent.ts (1)
  • BaseAgentOptions (7-9)
test/options.opaque.test.ts (2)
test/cjs/index.js (1)
  • assert (2-2)
examples/httpclient.cjs (1)
  • urllib (11-11)
🪛 Biome (2.1.2)
.oxlintrc.json

[error] 126-127: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)

🪛 GitHub Actions: CI
test/options.timeout.test.ts

[error] 96-96: TS2339: Property 'port' does not exist on type 'string | AddressInfo'.


[error] 174-174: TS2339: Property 'name' does not exist on type '{}'.

test/diagnostics_channel.test.ts

[error] 220-220: TS2531: Object is possibly 'null'.


[error] 220-220: TS2339: Property 'port' does not exist on type 'string | AddressInfo'.

test/options.stream.test.ts

[error] 85-85: TS2339: Property 'file' does not exist on type 'FormStream'.


[error] 86-86: TS2339: Property 'field' does not exist on type 'FormStream'.


[error] 92-92: TS2740: Type 'FormStream' is missing the following properties from type 'Readable': readableAborted, readable, readableDidRead, readableEncoding, and 52 more.


[error] 93-93: TS2339: Property 'headers' does not exist on type 'FormStream'.

test/urllib.options.rejectUnauthorized-false.test.ts

[error] 63-63: TS2339: Property 'port' does not exist on type 'string | AddressInfo'.

test/HttpClient.test.ts

[error] 160-160: TS2339: Property 'port' does not exist on type 'string | AddressInfo'.


[error] 223-223: TS2339: Property 'port' does not exist on type 'string | AddressInfo'.


[error] 414-414: TS6133: 'address' is declared but its value is never read.

test/mts/src/index.mts

[error] 1-1: TS2307: Cannot find module 'urllib' or its corresponding type declarations.


[error] 1-1: Cannot find module 'urllib' or its corresponding type declarations.

test/fixtures/server.ts

[error] 24-24: TS7053: Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'Socket'. Property '[requestsPerSocket]' does not exist on type 'Socket'.


[error] 30-30: TS7053: Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'Socket'. Property '[requestsPerSocket]' does not exist on type 'Socket'.


[error] 338-338: TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'.


[error] 348-348: TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'.

test/fixtures/socket_server.ts

[error] 15-15: TS6133: 'req' is declared but its value is never read.

🪛 LanguageTool
README.md

[style] ~60-~60: To form a complete sentence, be sure to include a subject.
Context: ...ng - Request method, defaults to GET. Could be GET, POST, DELETE or PUT. Al...

(MISSING_IT_THERE)


[uncategorized] ~61-~61: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’).
Context: ...a_** Object - Data to be sent. Will be stringify automatically. - content String...

(AUTO_HYPHEN)


[uncategorized] ~64-~64: Possible missing preposition found.
Context: ...ps://nodejs.org/api/stream.html#stream_class_stream_writable) - A writable stream t...

(AI_HYDRA_LEO_MISSING_TO)


[grammar] ~64-~64: Possible agreement error. The noun ‘phase’ seems to be countable.
Context: ...am.html#stream_class_stream_writable) - A writable stream to be piped by the response...

(CD_NN)


[style] ~66-~66: To form a complete sentence, be sure to include a subject or ‘there’.
Context: ...tType_** String - Type of request data. Could be json (Notes: not use `applicat...

(MISSING_IT_THERE)


[style] ~67-~67: To form a complete sentence, be sure to include a subject.
Context: ...Type_** String - Type of response data. Could be text or json. If it's text, th...

(MISSING_IT_THERE)


[misspelling] ~70-~70: Use ‘every thing’ if you want to emphasize that the things are separate. Usually, you can use “everything”.
Context: ...rs_** Object - Request headers. - timeout Number | Array - Request timeout in milli...

(EVERYTHING)


[uncategorized] ~70-~70: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’).
Context: ...timeout: 5000` to tell urllib use same timeout on two phase or set them separately such as ...

(AUTO_HYPHEN)


[misspelling] ~75-~75: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...- maxRedirects Number - The maximum number of redirects to follow, defaults...

(EN_A_VS_AN)


[uncategorized] ~78-~78: Possible missing article found.
Context: ...n - lets you get the res object when request connected, default false. alias `cust...

(AI_HYDRA_LEO_MISSING_A)


[uncategorized] ~81-~81: Loose punctuation mark.
Context: ...t is true. - socketPath String | null - request a unix socket service, ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~81-~81: Loose punctuation mark.
Context: ...String | null - request a unix socket service, default is null. - **_highWate...

(UNLIKELY_OPENING_PUNCTUATION)

🔇 Additional comments (111)
test/options.gzip.test.ts (1)

1-7: Formatting looks good.

The blank lines added around import groups align with standard formatting conventions and the oxfmt tool's style. No functional changes have been introduced—the test logic remains intact.

scripts/replace_urllib_version.js (1)

9-9: Formatting changes approved.

Both formatting updates align well with oxfmt standards and maintain code clarity:

  • Line 9: Single-line array declaration is more compact without sacrificing readability.
  • Line 14: Parentheses around arrow function parameters follow modern JavaScript conventions and improve consistency.

The script logic and functionality remain intact across these formatting adjustments.

Also applies to: 14-14

test/formData-with-BufferStream.test.ts (1)

1-9: Clean import organization following standard conventions.

The import reorganization groups imports logically (node built-ins → external packages → local modules) with appropriate blank-line separators for improved readability. This aligns well with the oxfmt configuration objectives.

test/urllib.options.rejectUnauthorized-false.test.ts (1)

1-10: Import organization looks good.

The imports are properly grouped by source (stdlib, third-party, local) with clear separation, which aligns with oxfmt conventions.

test/options.streaming.test.ts (2)

4-6: LGTM! Consistent import spacing.

The blank lines between import groups improve readability and align with the oxfmt formatting standards.


92-96: Formatting looks good, but verify error handling in pipeline callbacks.

The multi-line formatting of the pipeline calls improves readability. However, the empty callbacks don't handle potential pipeline errors. In test code, unhandled errors could cause tests to hang or pass incorrectly.

Consider handling errors in the pipeline callbacks:

     bytes = await readableToBytes(
-      pipeline(response.res, decoder, () => {
-        return;
-      }),
+      pipeline(response.res, decoder, (err) => {
+        if (err) throw err;
+      }),
     );

This pattern appears in both locations (lines 92-96 and 117-121).

Also applies to: 117-121

test/mts/src/index.mts (2)

4-4: IsAny conditional type change is purely formatting

Dropping the parentheses in 0 extends 1 & T ? Y : N doesn’t change the conditional type’s semantics here; 1 & T is still the right-hand side of extends. This looks like a safe, style-only tweak aligned with the formatter.

Please re-run the new typecheck task over this file to confirm there are no additional TS diagnostics beyond the known import-resolution issue.


1-2: Remove unsupported TS2307 claim; this file is not checked by CI typecheck

The CI workflow runs pnpm run typecheck (which is tsc --noEmit at the root level), but the root tsconfig.json does not include test/mts/**/* files. The test/mts/ directory has its own tsconfig.json that is only used when explicitly running build:mts:test or tsc -p test/mts/tsconfig.json, neither of which are in the CI pipeline. The referenced TS2307 error does not occur in the actual CI typecheck job.

Likely an incorrect or invalid review comment.

test/head-request-should-keepalive.test.ts (1)

1-8: LGTM! Formatting improvements align with oxfmt standards.

The added blank lines separate import groups for better readability. No functional changes.

test/options.retry.test.ts (1)

1-9: LGTM! Import grouping improves readability.

Blank lines added to separate import groups consistently with the rest of the test suite.

test/fetch-head-request-should-keepalive.test.ts (1)

1-8: LGTM! Consistent import formatting.

Formatting aligns with the oxfmt standardization across the test suite.

test/urllib.options.allowH2.test.ts (1)

1-6: LGTM! Formatting improvements.

Import spacing standardized per oxfmt configuration.

test/utils.test.ts (1)

1-6: LGTM! Import formatting standardized.

Consistent blank line spacing applied.

renovate.json (1)

1-4: LGTM! JSON formatting normalized.

The extends array formatting is now single-line, which is cleaner for a single-item array. No semantic change.

test/user-agent.test.ts (1)

1-7: LGTM! Import spacing standardized.

Consistent formatting applied across the test suite.

src/Response.ts (1)

1-4: LGTM! Import formatting improved.

Blank line added to separate external import from local imports, improving readability.

test/esm/index.js (1)

1-5: Formatting-only change; no functional impact.

The blank line added after the initial import improves readability and aligns with oxfmt formatting rules.

test/options.headers.test.ts (1)

1-6: Formatting-only change; no functional impact.

Blank lines added to separate import groups by source (built-in, third-party, project imports), improving readability per oxfmt standards.

test/options.method.test.ts (1)

1-6: Formatting-only change; no functional impact.

Blank lines added to separate import groups, improving readability and consistency per oxfmt standards.

test/mts/tsconfig.json (1)

2-8: Formatting-only change; no functional impact.

Indentation normalized to spaces and trailing commas added to JSON structure, improving consistency per oxfmt formatting standards. Configuration behavior remains unchanged.

test/options.timing.test.ts (1)

1-7: Formatting-only change; no functional impact.

Blank lines added to separate import groups by source, improving readability and consistency per oxfmt standards.

test/options.type.test.ts (1)

1-6: Formatting-only change; no functional impact.

Blank lines added to separate import groups, improving readability and consistency per oxfmt standards.

test/options.digestAuth.test.ts (1)

1-6: Formatting-only change; no functional impact.

Blank lines added to separate import groups, improving readability and consistency per oxfmt standards.

test/options.reset.test.ts (1)

1-6: Formatting-only change; no functional impact.

Blank lines added to separate import groups, improving readability and consistency per oxfmt standards.

.oxlintrc.json (1)

6-6: LGTM!

The single-line formatting of the extends array is consistent with the new oxfmt configuration.

src/BaseAgent.ts (1)

1-4: LGTM!

The import consolidation and spacing align with the new oxfmt formatting rules. No functional changes.

test/options.content.test.ts (1)

4-6: LGTM!

The import reordering and spacing are consistent with the new oxfmt formatting configuration.

test/keep-alive-header.test.ts (1)

3-5: LGTM!

The formatting improvements enhance readability, particularly for the multi-line assertions. All changes are consistent with the oxfmt configuration.

Also applies to: 93-96, 140-143, 176-176

vite.config.ts (1)

5-5: LGTM!

The single-line array formatting is consistent with the oxfmt configuration and maintains readability for these short arrays.

Also applies to: 8-8, 11-11

test/response-charset-gbk.test.ts (1)

2-2: LGTM!

The blank lines improve import grouping and align with the new oxfmt formatting rules.

Also applies to: 4-4

examples/timing.cjs (1)

22-30: LGTM!

The multi-line formatting with trailing comma improves readability and follows JavaScript best practices.

test/fixtures/ts/tsconfig.json (1)

9-11: LGTM!

The trailing comma addition is consistent with TypeScript configuration best practices and the oxfmt formatting rules.

test/options.socketPath.test.ts (1)

1-4: Import spacing change is purely stylistic

Added blank lines between node/vitest/local imports; behavior and test semantics are unchanged. Looks good.

examples/search_github.cjs (1)

5-14: Reformatted promise chain keeps behavior identical

The multi-line .request(...).then(...) formatting preserves the same options and logging; no functional change.

test/options.signal.test.ts (1)

24-40: assert.rejects blocks reformatted without changing logic

Both abort-related tests still create the same requests, trigger abort, await the same promises, and validate error shape via the custom predicate. Changes are cosmetic only.

Also applies to: 44-61

tsconfig.json (1)

8-9: tsconfig change is formatting-only

Only a trailing comma was added to compilerOptions; no compiler behavior or options were modified.

test/options.auth.test.ts (1)

1-4: Import formatting aligns with new style

Spacing between node/vitest/project imports is updated only; the auth test behavior remains identical.

examples/h2-other-side-closed-exit-0-fetch.cjs (1)

3-7: H2 dispatcher and main promise chain are unchanged semantically

The multiline setGlobalDispatcher(new Agent({ allowH2: true })) and main().then(...).catch(...) are equivalent to the prior single-line forms; runtime behavior is preserved.

Also applies to: 26-34

test/options.compressed.test.ts (1)

1-5: Compressed-options tests keep the same assertions

Import spacing, the assert(!requestHeaders['accept-encoding'], ...) reflow, and both assert.rejects blocks for invalid gzip/brotli remain logically equivalent to the previous version; no behavior change.

Also applies to: 41-44, 173-190, 194-214

test/options.fixJSONCtlChars.test.ts (1)

1-4: JSON control-character test assertion is structurally refactored only

The assert.rejects call still exercises the same failing request and validates the same error properties; only formatting and layout changed.

Also applies to: 34-49

examples/longruning.cjs (1)

24-32: LGTM! Promise chain formatting looks clean.

The multi-line formatting improves readability while preserving the original error handling logic.

test/fixtures/ts-esm/tsconfig.json (1)

9-11: LGTM! Trailing comma added for cleaner diffs.

The formatting change follows JSON best practices without affecting the configuration.

test/fixtures/ts-cjs-es2021/tsconfig.json (1)

9-11: LGTM! Consistent formatting with other tsconfig files.

Trailing comma added for better maintainability.

examples/h2-other-side-closed-exit-0.cjs (2)

3-7: LGTM! Multi-line formatting improves readability.

The setGlobalDispatcher call is now easier to read with one argument per line.


26-34: LGTM! Promise chain formatting is consistent.

The error handling logic remains unchanged while improving code clarity.

test/options.dataType.test.ts (3)

2-4: LGTM! Import spacing normalized.

Consistent blank line spacing improves code organization.


104-134: LGTM! Test assertion formatting improved.

The assert.rejects call is more readable with multi-line formatting while preserving all error validation logic.


147-161: LGTM! Consistent assertion formatting.

The test logic remains unchanged with improved readability.

test/options.followRedirect.test.ts (3)

3-5: LGTM! Import spacing normalized.

Consistent formatting across test files.


82-82: LGTM! Array formatting consolidated.

Single-line format is cleaner for simple arrays.


94-94: LGTM! Consistent array formatting.

Matches the formatting style applied throughout the file.

test/non-ascii-request-header.test.ts (2)

2-4: LGTM! Import spacing normalized.

Consistent with the formatting applied to other test files.


23-40: LGTM! Test assertion formatting improved.

Multi-line formatting enhances readability while preserving the error validation logic.

README.md (1)

59-82: LGTM! Documentation formatting updated consistently.

The change from bold to italic emphasis for option names provides a cleaner, more consistent documentation style across the arguments list.

test/options.dispatcher.test.ts (1)

1-7: LGTM - Formatting changes align with oxfmt standardization.

Import reordering and blank line additions are consistent with the formatting tool configuration.

test/index.test.ts (2)

1-15: LGTM - Import reordering and formatting standardization.

The import reorganization follows the expected pattern: node modules first, then external packages, then local imports with appropriate blank line separators.


207-247: LGTM - Improved mock intercept readability with fluent chaining.

The reformatted mockPool.intercept(...).reply(...) pattern is more readable than the previous style.

src/index.ts (1)

90-129: LGTM - Export declarations reformatted for clarity.

One export per line improves readability and produces cleaner diffs when exports are added or removed.

test/options.stream.test.ts (1)

111-128: LGTM - assert.rejects formatting standardized.

The multi-line callback style for assert.rejects is consistent with the formatting applied across other test files.

src/FormData.ts (1)

28-35: LGTM - Quote style normalization.

The change from escaped single quotes to double quotes produces identical output while improving readability. The Content-Disposition header construction remains correct per RFC 6266.

test/options.writeStream.test.ts (2)

1-12: LGTM - Import reordering and formatting standardization.

Import organization follows the consistent pattern established across the test suite.


87-101: LGTM - assert.rejects formatting consistent with test suite.

The multi-line callback style aligns with the formatting applied across other test files in this PR.

test/options.files.test.ts (2)

1-11: LGTM - Import reordering follows formatting standards.

The import organization is consistent with the patterns established across the test suite.


43-56: LGTM - assert.rejects formatting standardized.

The multi-line callback style is consistent with other test files in this PR.

src/Request.ts (3)

2-5: LGTM! Import reorganization aligns with oxfmt.

The import statements have been reorganized for consistency. The changes maintain the same functionality while improving code style.


44-50: LGTM! Multiline formatting improves readability.

The files option type has been reformatted to a clearer multiline structure, making the union type easier to read without changing its behavior.


176-176: LGTM! Consistent type annotation punctuation.

The trailing semicolon aligns with TypeScript best practices and the formatting standards being applied across the codebase.

test/fixtures/socket_server.ts (2)

7-10: LGTM! Consistent type annotation style.

The type annotation has been updated to use semicolons instead of commas, aligning with the formatting standards being applied across the codebase.


21-27: LGTM! Consistent arrow function parameter formatting.

The explicit parentheses around arrow function parameters improve consistency and align with the formatting standards.

test/options.data.test.ts (1)

1-555: LGTM! Consistent formatting improvements throughout the file.

The formatting changes improve readability by:

  • Adding appropriate blank lines after imports
  • Reformatting multiline assertions and object literals for clarity
  • Standardizing array and object spacing

All changes are non-functional and align with the oxfmt formatting standards being applied across the codebase.

test/fetch.test.ts (2)

4-10: LGTM! Import organization improvements.

The imports have been consolidated and reorganized for better clarity, including the addition of the Request import from undici which is used later in the test.


30-139: LGTM! Consistent formatting for arrow functions and arrays.

The changes standardize:

  • Arrow function parameters with explicit parentheses
  • Array spacing to be more compact
  • Multiline assertion formatting for better readability

All changes maintain the same functionality while improving code consistency.

src/utils.ts (3)

1-8: LGTM! Improved import organization.

The imports have been reorganized to:

  • Group related imports (Blob and File from node:buffer)
  • Make explicit the import of IncomingHttpHeaders
  • Improve overall clarity

All changes maintain the same functionality.


49-165: LGTM! Consistent multiline formatting.

The multiline formatting of error messages and the isReadable return statement improves readability without changing behavior. These changes align with the formatting standards being applied across the codebase.


207-279: LGTM! Minor spacing and formatting adjustments.

The spacing adjustments in loops and function definitions maintain consistency with the formatting standards. All changes are non-functional.

src/HttpAgent.ts (3)

3-4: LGTM! Import formatting improvement.

The imports have been formatted for better consistency.


13-13: LGTM! Consistent type annotation style.

The type annotation has been updated to use a semicolon, aligning with TypeScript best practices and the formatting standards being applied across the codebase.


53-59: LGTM! Improved address validation logic.

The changes include:

  1. Consistent type annotation formatting with semicolons
  2. Addition of a break statement after detecting an invalid address

The break statement is a functional improvement that prevents unnecessary iterations once an invalid address is found, making the validation more efficient.

package.json (4)

27-29: LGTM! New formatting scripts added.

The addition of fmt, typecheck, and fmtcheck scripts supports the oxfmt formatting initiative. These scripts provide essential tooling for maintaining code quality and consistency.


77-77: LGTM! oxfmt dependency added.

The oxfmt formatter has been added as a dev dependency to support the formatting initiative described in the PR objectives.


119-119: LGTM! Package manager specified.

The packageManager field has been added to specify pnpm version 10.24.0, which helps ensure consistent package management across different environments.


46-46: LGTM! CI script updated.

The CI script has been appropriately streamlined for its publishing validation purpose. Linting is still covered in the CI pipeline—it runs in the GitHub Actions workflow (.github/workflows/nodejs.yml) and is also included as part of the test script.

src/FetchOpaqueInterceptor.ts (1)

2-3: LGTM! Improved import spacing.

The addition of a blank line after the import improves readability and aligns with the formatting standards being applied across the codebase.

.github/workflows/release.yml (1)

3-5: Workflow branch filter normalization looks good

Switching to branches: [master] is a style-only change and keeps the trigger behavior identical.

.github/workflows/nodejs-16.yml (1)

3-7: CI trigger and step formatting are consistent

Standardizing to branches: [master] and the minor step formatting change do not affect behavior and keep this workflow aligned with the others.

Also applies to: 22-22

src/IncomingHttpHeaders.ts (1)

1-7: Import reordering is safe

Grouping the type-only Except import after the Node built-in import is purely stylistic; the IncomingHttpHeaders type remains unchanged.

test/utils.ts (1)

1-7: Import order cleanup only

Reordering the imports here doesn’t change runtime behavior; the helpers continue to work as before.

src/HttpClientError.ts (1)

1-14: Explicit type import for response metadata is correct

Importing RawResponseWithMeta and SocketInfo as types from Response.js matches their usage on HttpClientRequestError and keeps runtime dependencies unchanged.

.oxfmtrc.json (1)

1-18: oxfmt configuration is coherent with repo style

The schema reference, print width, single-quote preference, ignore patterns, and import-sorting groups all look consistent with the formatting changes in source and test files.

test/HttpClient.connect.rejectUnauthorized.test.ts (1)

28-41: Reformatted assert.rejects blocks preserve behavior

The reshaped assert.rejects calls still assert on err.name, err.message, err.code, and err.res.status as before. Only style changed; behavior remains correct.

Also applies to: 47-60

test/options.timeout.test.ts (6)

3-8: New imports for HTTP/2 and timeout error type are appropriate

Importing createSecureServer and HttpClientRequestTimeoutError matches their usage in the h2 timeout test and the last timeout test.


29-49: HeadersTimeout test formatting change is safe

Reflowing this assert.rejects block doesn’t alter the checks on err.name, err.message, err.cause.*, and err.res timing; behavior is unchanged.


52-73: String timeout test remains valid after reformat

The test still verifies that a string timeout: '10' is handled correctly and produces the expected HttpClientRequestTimeoutError with HeadersTimeoutError as the cause.


120-138: BodyTimeout test reformat is behavior‑preserving

The assert.rejects block still checks for HttpClientRequestTimeoutError with optional BodyTimeoutError cause and status 200. Only formatting changed.


142-157: Array timeout [400, 500] test remains unchanged semantically

The refactored assert.rejects block continues to assert the correct timeout message, status, and BodyTimeoutError cause when present.


160-177: Change callback parameter type to any to fix TS2339 error on line 174

The callback in assert.rejects tries to access err.cause.name, but HttpClientRequestTimeoutError doesn't explicitly declare a cause property. Match the pattern used in all other timeout tests in this file by changing the parameter type:

-      (err: HttpClientRequestTimeoutError) => {
+      (err: any) => {
         // console.log(err);
         assert.equal(err.name, 'HttpClientRequestTimeoutError');
         assert.equal(err.message, 'Request timeout for 100 ms');
         assert.equal(err.res!.status, -1);
         assert(err.headers);
         assert.equal(err.status, -1);
         err.cause && assert.equal(err.cause.name, 'HeadersTimeoutError');
         return true;
       },
.github/workflows/nodejs.yml (1)

11-46: LGTM! Excellent addition of comprehensive pre-test checks.

The new typecheck job adds valuable quality gates including linting, dependency deduplication checks, TypeScript type checking, formatting verification, and build validation before running tests. This will catch issues earlier in the CI pipeline.

test/HttpClient.events.test.ts (1)

1-135: LGTM! Formatting improvements for consistency.

The changes apply consistent formatting across the file, including standardized arrow function parameter syntax and improved readability of assertion blocks. No behavioral changes.

test/options.opaque.test.ts (1)

1-54: LGTM! Consistent formatting applied.

Formatting improvements align with the repository-wide oxfmt standardization. No functional changes.

test/options.socketErrorRetry.test.ts (1)

1-98: LGTM! Formatting standardization applied.

Consistent formatting improvements throughout the file. No behavioral changes to the test logic.

examples/httpclient.cjs (1)

1-28: LGTM! Formatting standardization.

Adds consistent spacing after the function keyword throughout the file. No functional changes.

test/HttpClient.test.ts (1)

1-29: LGTM! Formatting improvements.

The PerformanceObserver callback and array formatting updates improve readability. These are formatting-only changes.

test/diagnostics_channel.test.ts (1)

1-15: LGTM! Import organization improvements.

The import reordering and separation of type imports improve code organization. These are formatting-only changes.

src/fetch.ts (3)

1-38: LGTM! Import organization improvements.

The import consolidation and reorganization improve code structure and readability. No functional changes.


115-116: LGTM! Improved loop clarity.

The explicit destructuring in the for-of loop makes the code more readable. The type assertion formatting is also clearer.


263-270: LGTM! Debug call formatting improvement.

Breaking the debug call across multiple lines improves readability without changing behavior.

src/diagnosticsChannel.ts (2)

2-3: Typed Socket usage and connect error instrumentation look consistent.

Importing Socket from node:net, annotating SocketExtend, and wiring Socket.prototype.destroy to attach symbols.kErrorSocket preserves existing behavior and improves type safety. The updated undici:client:connectError handler, including socket: SocketExtend in the cast and using the same SocketExtend for the fallback from error[symbols.kErrorSocket], is coherent and keeps the error/socket correlation clear.

Also applies to: 59-68, 122-154


108-120: Structured debug logging with formatSocket is a good improvement.

The multi-line debug(...) calls for request creation, header sending, and response headers, plus switching to formatSocket(socket) / formatSocket(sock) instead of logging the raw socket, make diagnostics more readable and avoid dumping huge socket objects while still surfacing key connection metadata.

Also applies to: 186-205, 233-253

test/fixtures/server.ts (1)

68-86: Formatting changes to JSON responses, headers, and server lifecycle look good.

The multi-line res.end(JSON.stringify(...)) calls, normalized digest auth www-authenticate / x-www-authenticate headers, proper Set-Cookie casing for multiple cookies, and the Promise-wrapped startServer/closeServer structure all preserve behavior while improving readability and consistency.

Also applies to: 88-119, 121-152, 163-185, 203-207, 317-357, 442-464

src/HttpClient.ts (2)

216-238: Improved typing for undici pool stats looks correct.

Casting clients from undiciSymbols.kClients to Map<string, WeakRef<Pool>> | undefined and normalizing ref via typeof ref.deref === 'function' ? ref.deref() : ref (then checking both pool.stats and pool.dispatcher.stats) safely handles both the older and undici@v7 shapes. Using PoolStat with satisfies is a nice touch to keep the mapping structurally checked.


251-257: Request pipeline, upload handling, redirects, and digest auth changes are semantically sound.

The refactoring of #requestInternal to multi-line parameters, the files/FormData upload handling using FormStream compatibility, the nested querystring support via qs, the more detailed debug logs (including timing and socket info), the digest-auth retry block, and the socket-error retry debug are all consistent with the existing behavior and improve readability without introducing new logic.

Also applies to: 462-512, 526-562, 575-587, 596-625, 643-651, 712-719, 751-757, 771-775

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 8, 2025

Open in StackBlitz

npm i https://pkg.pr.new/node-modules/urllib@602

commit: f4f4e16

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 8, 2025

Open in StackBlitz

npm i https://pkg.pr.new/node-modules/urllib@602

commit: 753db48

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
test/fixtures/server.ts (2)

1-32: startServer wiring, per-socket tracking, and HTTPS/closeServer behavior all look sound

Imports (including Socket, compression helpers, and selfsigned), the startServer options/return type, per-socket request counting via a Symbol, and the HTTPS server creation/closeServer helper are consistent with Node’s HTTP APIs and preserve the previous behavior while keeping Node 16+ connection shutdown logic intact. If you ever want tighter typing, you could narrow the closeServer property from any to () => Promise<void> in the return type, but it’s not required for these test fixtures.

Also applies to: 414-460


318-357: Multipart and form-url-encoded parsing remain correct; typing tweaks are fine but could be stronger

The /multipart busboy setup still only records file metadata plus fields and responds with the aggregated result, and the application/x-www-form-urlencoded branch still builds requestBody from either qs.parse or URLSearchParams as before. The new files/form assertions to Record<string, any> are acceptable for tests; optionally, you could introduce explicit interfaces for file entries and form fields to avoid any and catch shape mismatches at compile time.

Also applies to: 371-386

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed6afda and 753db48.

📒 Files selected for processing (11)
  • .github/workflows/nodejs.yml (1 hunks)
  • src/formstream.d.ts (1 hunks)
  • test/HttpClient.test.ts (9 hunks)
  • test/diagnostics_channel.test.ts (4 hunks)
  • test/fixtures/server.ts (9 hunks)
  • test/fixtures/socket_server.ts (1 hunks)
  • test/mts/src/index.mts (1 hunks)
  • test/options.stream.test.ts (4 hunks)
  • test/options.timeout.test.ts (3 hunks)
  • test/urllib.options.rejectUnauthorized-false.test.ts (2 hunks)
  • tsconfig.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • test/options.timeout.test.ts
  • .github/workflows/nodejs.yml
  • test/options.stream.test.ts
  • test/HttpClient.test.ts
  • tsconfig.json
🧰 Additional context used
🧬 Code graph analysis (2)
test/diagnostics_channel.test.ts (2)
test/cjs/index.js (1)
  • assert (2-2)
examples/httpclient.cjs (1)
  • urllib (11-11)
test/fixtures/server.ts (1)
test/fixtures/socket_server.ts (1)
  • startServer (6-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Test (windows-latest, 22)
  • GitHub Check: Test (macos-latest, 18)
  • GitHub Check: Test (windows-latest, 18)
🔇 Additional comments (8)
test/mts/src/index.mts (2)

1-3: Import and top-level await with @ts-expect-error look correct

Directive syntax is valid with a message, import style matches the formatter, and using top-level await in this .mts test context is appropriate. No issues from a typing or runtime perspective here.


5-5: IsAny conditional type change is a no-op and remains canonical

Dropping the parentheses in 0 extends 1 & T doesn’t change semantics; the helper still behaves as intended in the assertions below. Good cleanup.

test/urllib.options.rejectUnauthorized-false.test.ts (1)

4-7: Typed port extraction from server.address() looks correct

Using AddressInfo for server.address() and interpolating https://localhost:${(server.address() as AddressInfo).port} after awaiting the 'listening' event is type-safe and matches the expected Node http2 server typings; behavior is unchanged and clearer than a non-null assertion.

Also applies to: 11-11, 64-64

test/diagnostics_channel.test.ts (3)

4-9: Import re-org and type-only import are consistent and safe

Reordered imports, separating the import type { … } from the value import and adding AddressInfo, align with modern TS + Node style and don’t change runtime behavior.

Also applies to: 11-11, 15-15


220-222: Using AddressInfo for H2 server URL construction is appropriate

Assigning _url = \https://localhost:${(server.address() as AddressInfo).port}`afterlisten(0)and'listening'` ensures a non-null, correctly typed port from the HTTP/2 secure server; behavior matches the previous implementation while improving typing clarity.


390-414: Updated assert.rejects validators keep error semantics intact

Wrapping the urllib.request calls in async functions and using validator callbacks that assert on lastError, error name/message, codes, and socket references (then return true) is a correct use of assert.rejects; it preserves the original expectations while making the checks more explicit and thorough.

Also applies to: 443-464

test/fixtures/server.ts (1)

69-208: Auth JSON handlers and cookie behavior are preserved despite formatting changes

The /auth, /hello/json, and various digest auth endpoints still emit the same JSON payloads and www-authenticate/x-www-authenticate header values, and changing /set-two-cookie to use 'Set-Cookie' casing remains HTTP-equivalent since Node normalizes header names, so these edits are effectively formatting-only.

test/fixtures/socket_server.ts (1)

6-30: Unix-socket startServer formatting and typing adjustments look good

The semicolon-separated return type, Promise executor parentheses, and renaming the unused req parameter to _req are all stylistic; the server still listens on a unique Unix socket path, responds with the same JSON payload, and exposes a closeServer that wraps unixSocketServer.close in a Promise, matching the HTTP fixture’s behavior.

@fengmk2 fengmk2 merged commit 948f05d into master Dec 8, 2025
21 of 23 checks passed
@fengmk2 fengmk2 deleted the oxfmt branch December 8, 2025 14:43
fengmk2 pushed a commit that referenced this pull request Dec 13, 2025
[skip ci]

## 4.9.0 (2025-12-13)

* feat: enable isolatedDeclarations (#615) ([374402e](374402e)), closes [#615](#615) [hi#level](https://github.com/hi/issues/level)
* chore: enable oxfmt (#602) ([948f05d](948f05d)), closes [#602](#602) [hi#level](https://github.com/hi/issues/level)
* chore: enable tsgo on typecheck (#605) ([41f6277](41f6277)), closes [#605](#605) [hi#level](https://github.com/hi/issues/level)
* chore: fix auto release ([8f13384](8f13384))
* chore(deps): update actions/checkout action to v6 (#600) ([75685a1](75685a1)), closes [#600](#600)
* chore(deps): update actions/setup-node action to v6 (#596) ([d4fd7cf](d4fd7cf)), closes [#596](#596)
* chore(deps): update codecov/codecov-action digest to 671740a (#608) ([2734504](2734504)), closes [#608](#608)
* chore(deps): update dependency @tsconfig/node18 to v18.2.6 (#603) ([23ffca2](23ffca2)), closes [#603](#603)
* chore(deps): update dependency @tsconfig/strictest to v2.0.8 (#604) ([0fc042a](0fc042a)), closes [#604](#604)
* chore(deps): update dependency @types/node to v22.19.2 (#610) ([a9ace96](a9ace96)), closes [#610](#610)
* chore(deps): update dependency @typescript/native-preview to v7.0.0-dev.20251210.1 (#609) ([dc1ed3e](dc1ed3e)), closes [#609](#609)
* chore(deps): update dependency @typescript/native-preview to v7.0.0-dev.20251211.1 (#613) ([8f6fdaa](8f6fdaa)), closes [#613](#613)
* chore(deps): update dependency @typescript/native-preview to v7.0.0-dev.20251213.1 (#619) ([11b3bec](11b3bec)), closes [#619](#619)
* chore(deps): update dependency cross-env to v10.1.0 (#612) ([0f68029](0f68029)), closes [#612](#612)
* chore(deps): update dependency form-data to v4.0.5 (#606) ([ab3d22f](ab3d22f)), closes [#606](#606)
* chore(deps): update dependency oxlint to v1.32.0 (#614) ([8118abb](8118abb)), closes [#614](#614)
* chore(deps): update dependency typescript to v5.9.3 (#607) ([cda0e13](cda0e13)), closes [#607](#607)
* chore(deps): update dependency undici to v7.16.0 (#617) ([ca378bc](ca378bc)), closes [#617](#617)
* chore(deps): update pnpm to v10.25.0 (#618) ([708b985](708b985)), closes [#618](#618)
@github-actions
Copy link

🎉 This PR is included in version 4.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants