Skip to content

feat: support proxies - #194

Merged
hustcer merged 3 commits into
hustcer:mainfrom
vyadh:feature/proxies
Dec 13, 2025
Merged

feat: support proxies#194
hustcer merged 3 commits into
hustcer:mainfrom
vyadh:feature/proxies

Conversation

@vyadh

@vyadh vyadh commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

This PR adds support for proxy variables like HTTPS_PROXY using the recommended example in octokit/rest.js#43.

I've confirmed this working through a corporate proxy. It looks like you can just turn it on and it'll work without a proxy too, as can be seen on this run.

Summary by CodeRabbit

  • New Features

    • Proxy-enabled GitHub API requests — API calls can be routed through configured proxies to support network environments requiring a proxy.
  • Chores

    • Added a runtime HTTP library dependency to support the proxy-enabled request implementation.

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

@coderabbitai

coderabbitai Bot commented Dec 12, 2025

Copy link
Copy Markdown

Walkthrough

Adds undici as a runtime dependency and configures a proxy-enabled fetch (using EnvHttpProxyAgent + undici.fetch) in the setup module, then wires that proxied fetch into Octokit’s request layer so GitHub API calls go through the proxy-enabled fetch.

Changes

Cohort / File(s) Summary
Dependency Addition
package.json
Added undici (^7.16.0) as a runtime dependency.
Proxy-Enabled API Setup
src/setup.ts
Imported EnvHttpProxyAgent and undici's fetch, implemented a proxyFetch wrapper that applies the proxy agent (singleton proxyAgent) and wired it into Octokit's request.fetch so HTTP requests use the proxied fetch.

Sequence Diagram(s)

sequenceDiagram
    participant Setup as Setup module
    participant Octokit as Octokit (request layer)
    participant ProxyFetch as proxyFetch (undici.fetch wrapper)
    participant Agent as EnvHttpProxyAgent
    participant GitHub as GitHub API

    Setup->>Octokit: set request.fetch = proxyFetch
    Note right of Setup: proxyFetch uses a singleton proxyAgent\nand calls undici.fetch under the hood
    Octokit->>ProxyFetch: perform HTTP request
    ProxyFetch->>Agent: obtain/apply proxy agent (env-derived)
    ProxyFetch->>GitHub: send proxied HTTP request
    GitHub-->>ProxyFetch: return response
    ProxyFetch-->>Octokit: return response
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Review src/setup.ts for correct proxy agent lifecycle (singleton) and error handling.
  • Confirm Octokit wiring (request.fetch) is applied correctly and compatible with existing request options.
  • Check package.json change for lockfile/update implications.

Poem

A rabbit tucks a proxy cap on tight,
Hops through tunnels in the pale moonlight,
Fetches wrapped in soft-formed art,
Pinging servers, doing its part,
Happy hops, requests take flight — 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 pull request title 'feat: support proxies' directly and clearly summarizes the main change—adding proxy support for environment variables like HTTPS_PROXY.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f062ef6 and 03fea7c.

📒 Files selected for processing (1)
  • src/setup.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/setup.ts

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

@github-actions

Copy link
Copy Markdown

Code Analysis

  • Core Requirements: The code introduces undici as a dependency and implements a custom HTTP proxy agent for Octokit requests. This is a backend Node.js setup script, not a frontend React/Vue component. The ES specification compliance and component design patterns are not applicable here. The state management is handled via function parameters and async/await, which is appropriate for this context.
  • Framework Conventions: This is a TypeScript Node.js script for a GitHub Action, not a frontend framework code. The changes are related to HTTP request handling and proxy configuration.
  • Accessibility: Not applicable for backend setup scripts.

Security Review

  • Vulnerability Findings:
    • ❗ The proxyFetch function passes opts directly using spread operator without validation. This could allow unintended options to be passed to undiciFetch, potentially bypassing security configurations.
    • ⚠️ The EnvHttpProxyAgent uses default timeout values (10ms) which might be too aggressive for some network environments, potentially causing unnecessary request failures.
    • ⚠️ The undici dependency is added without version pinning to a specific patch version (^7.16.0), which could introduce breaking changes or vulnerabilities in future updates.

Optimization Suggestions

  • Performance Improvements:
    • Consider implementing request caching for release data to reduce API calls, especially since checkLatest = false is a common case.
    • The proxy agent is created for every getRelease call. Consider creating a singleton agent instance that can be reused across multiple requests.
    • Add connection pooling configuration to the proxy agent for better performance under high concurrency.

Overall Quality: 3

Note: This code review focuses on backend Node.js/TypeScript code for a GitHub Action setup script, not frontend React/Vue code as specified in the original instructions. The assessment criteria have been adjusted accordingly since the provided diff shows infrastructure code rather than frontend component code.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91bd6e3 and b0054c7.

⛔ Files ignored due to path filters (2)
  • dist/index.js is excluded by !**/dist/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json (1 hunks)
  • src/setup.ts (2 hunks)
🔇 Additional comments (1)
package.json (1)

24-31: No Node version incompatibility. The action is configured to use Node 24 in action.yaml (line 41), which exceeds the minimum requirement for [email protected] (Node.js >= 20.18.1).

Comment thread src/setup.ts Outdated
Comment thread src/setup.ts Outdated
@github-actions

Copy link
Copy Markdown

Code Analysis

  • Core Requirements: The changes introduce undici as a dependency and implement a proxy-aware HTTP client for the Octokit instance. This aligns with modern Node.js practices by using a more performant HTTP client than the built-in fetch or older libraries. The code follows good separation of concerns by encapsulating the proxy logic in a proxyFetch function.
  • Component Design Patterns: While this is a Node.js script, the pattern of creating a configurable client (Octokit) with a custom fetch implementation is sound. The proxyFetch function is a factory pattern that returns a configured fetch function.
  • State Management: Not applicable in this context (setup script).
  • Accessibility: Not applicable.

Security Review

  • XSS Prevention: Not applicable (backend script).
  • CSRF Protection: Not applicable (backend script).
  • Third-party Dependency: The addition of undici is a positive security move as it's a modern, well-maintained HTTP client. However, ensure it's kept updated to avoid known vulnerabilities.
  • Sensitive Data Handling: The githubToken is passed to Octokit, which is appropriate. The proxy agent uses environment variables (implied by EnvHttpProxyAgent), which is a standard and secure way to handle proxy configuration.

Optimization Suggestions

  • Performance: Using undici can improve HTTP request performance due to its connection pooling and lower overhead compared to Node's built-in http/https modules or older libraries.
  • Bundle Size: Adding undici increases the installation size, but this is acceptable for a backend tool where bundle size is less critical than in frontend applications.
  • Memory Leaks: Ensure the EnvHttpProxyAgent instances are properly managed. Currently, a new agent is created for each proxyFetch call, which could lead to excessive resource usage if getRelease is called frequently. Consider creating a singleton agent instance if performance profiling indicates an issue.

Overall Quality: 4

Rationale: The changes are well-structured and address a specific need (proxy support) using a modern library. The code is clean and follows good practices. The quality rating is 4 (out of 5) because:

  1. Strengths: Good use of a modern HTTP client, clear code, and proper configuration pattern.
  2. Minor Concern: The potential for creating multiple EnvHttpProxyAgent instances might be inefficient, though it's likely negligible in this specific use case. A singleton pattern for the agent could be a future optimization if needed.
  3. Missing: There's no error handling around the undici import or the proxyFetch function. While unlikely to fail, adding a try-catch or validation (e.g., checking if undiciFetch is defined) would improve robustness.

Example Improvement (Error Handling):

import { EnvHttpProxyAgent, fetch as undiciFetch } from 'undici';

// ... later in getRelease ...

const proxyFetch = (url: string, opts: any) => {
  // Ensure undiciFetch is available
  if (typeof undiciFetch !== 'function') {
    throw new Error('undici fetch is not available');
  }
  return undiciFetch(url, {
    ...opts,
    dispatcher: new EnvHttpProxyAgent(),
  });
};

Comment thread src/setup.ts Outdated
Comment thread src/setup.ts Outdated
@github-actions

Copy link
Copy Markdown

Code Analysis

  • Core Requirements: The code changes introduce undici as a dependency and implement a proxy-aware HTTP agent for the Octokit client. This improves network request handling by enabling HTTP proxy support and connection pooling. The implementation follows singleton pattern for the proxy agent, which is appropriate for resource management.
  • ES Specification Compliance: Uses ES modules syntax correctly with import statements. The addition of type imports for Undici types is TypeScript-compliant.
  • Component Design Patterns: While this is backend code, the singleton pattern for proxyAgent is appropriately implemented for efficient resource usage.
  • State Management: Not applicable to this setup code, but the singleton approach ensures consistent proxy configuration across requests.

Security Review

  • XSS Prevention: Not applicable as this is backend setup code without user-facing HTML.
  • CSRF Protection: Not applicable for GitHub API requests from a server context.
  • Third-party Dependency: ✅ undici is a modern, well-maintained HTTP client from the Node.js team. Version ^7.16.0 is recent and receives security updates.
  • Sensitive Data Handling: ✅ GitHub token is properly passed via auth parameter to Octokit constructor. No hardcoded credentials observed.
  • Proxy Security: The EnvHttpProxyAgent automatically reads proxy configuration from environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY). This is secure as it relies on system/CI environment configuration rather than hardcoded values.

Optimization Suggestions

  • Connection Pooling: ✅ The singleton proxyAgent enables connection reuse across requests, reducing TCP handshake overhead.
  • Resource Management: ✅ Proper use of singleton pattern prevents multiple agent instances.
  • Bundle Size: ⚠️ Adding undici increases bundle size (~300KB), but this is acceptable for a backend action where bundle size is less critical than for frontend code.
  • Performance Metrics: Consider adding metrics to track request latency through the proxy vs direct connections for monitoring purposes.

Overall Quality: 4/5

The changes are well-implemented with proper proxy support and connection pooling. The code follows modern Node.js patterns and maintains security best practices. The only minor consideration is the bundle size increase, which is acceptable for this use case.

@hustcer
hustcer merged commit fcc7211 into hustcer:main Dec 13, 2025
10 checks passed
@hustcer

hustcer commented Dec 13, 2025

Copy link
Copy Markdown
Owner

Thanks

@github-actions github-actions Bot added this to the v3.22 milestone Dec 13, 2025
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.

2 participants