Skip to content

Conversation

@betschki
Copy link
Contributor

@betschki betschki commented Nov 21, 2025

Significantly improved proxy performance by switching from http-proxy to fast-proxy with undici backend. Proxy overhead reduced from 120-286ms to near-zero through connection pooling and HTTP pipelining.

  • Add fast-proxy and undici dependencies
  • Rewrite middleware.ts to use fast-proxy with undici
  • Configure 100 persistent connections with HTTP pipelining
  • Add URL caching for 1000 parsed URLs
  • Remove http-proxy and related type dependencies
  • Bump version to 1.3.0

Summary by CodeRabbit

  • New Features

    • HTTP request pipelining support (10 concurrent requests)
    • Connection pooling for optimized request handling (100 connections)
    • URL caching for faster processing (1,000 entries)
  • Bug Fixes

    • Enhanced error handling with improved error page display
  • Chores

    • Release v1.3.0

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

Significantly improved proxy performance by switching from http-proxy
to fast-proxy with undici backend. Proxy overhead reduced from
120-286ms to near-zero through connection pooling and HTTP pipelining.

- Add fast-proxy and undici dependencies
- Rewrite middleware.ts to use fast-proxy with undici
- Configure 100 persistent connections with HTTP pipelining
- Add URL caching for 1000 parsed URLs
- Remove http-proxy and related type dependencies
- Bump version to 1.3.0
@coderabbitai
Copy link

coderabbitai bot commented Nov 21, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Package version bumped to 1.3.0 with http-proxy replaced by fast-proxy and undici for improved performance. Updated middleware implements new request/response header rewriting logic, enhanced error handling with static HTML pages, and introduces a public close method for connection management.

Changes

Cohort / File(s) Summary
Version & Dependency Updates
package.json
Version bumped 1.2.0 → 1.3.0; removed http-proxy, @types/http-proxy, @types/http-proxy-middleware; added fast-proxy and undici
Release Documentation
CHANGELOG.md
New 1.3.0 entry documenting http-proxy → fast-proxy/undici migration, connection pooling (100), HTTP pipelining (10 deep), and URL caching (1000 entries)
Proxy Implementation
src/middleware.ts
Major refactoring: replaced http-proxy with fast-proxy; new header rewriting (x-forwarded-for, x-real-ip), cache invalidation detection; improved error handling with static HTML pages; added public close() method; removed event listeners and direct piping

Sequence Diagram

sequenceDiagram
    participant Client
    participant Middleware as ProxyMiddleware
    participant FastProxy as fast-proxy
    participant Backend

    Client->>Middleware: HTTP Request
    activate Middleware
    Middleware->>Middleware: rewriteRequestHeaders<br/>(x-forwarded-for, x-real-ip)
    Middleware->>FastProxy: proxyFn(request, rewrite hooks)
    activate FastProxy
    FastProxy->>Backend: Forward with<br/>rewritten headers
    activate Backend
    Backend-->>FastProxy: HTTP Response
    deactivate Backend
    FastProxy->>Middleware: Response headers
    Middleware->>Middleware: rewriteHeaders<br/>(detect x-cache-invalidate,<br/>filter sensitive headers)
    Middleware-->>Client: Response
    deactivate FastProxy
    deactivate Middleware
    
    Note over Middleware: On error: handleProxyError<br/>renders static HTML page
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • src/middleware.ts: Critical focus area—significant logic refactoring with new header rewriting, error handling, and close management. Verify x-forwarded-for/x-real-ip computation logic, cache invalidation detection, and error page rendering conditions.
  • Fast-proxy integration: Confirm proper initialization via createRequire and rewrite hook lifecycle.
  • Type definitions: Validate new FastProxyOptions and ProxyFunction types align with fast-proxy API.

Poem

🐰 A proxy swift, with wings so fast,
Fast-proxy soars where old ones passed,
Undici's pool flows deep and wide,
Headers rewritten, clients worldwide,
Connection pooling—performance's pride! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch switch-proxy

📜 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 af220ae and 57a4655.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • package.json (2 hunks)
  • src/middleware.ts (2 hunks)

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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

@betschki betschki merged commit 8549ec0 into main Nov 21, 2025
1 of 2 checks passed
@betschki betschki deleted the switch-proxy branch November 21, 2025 20:42
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