Skip to content

test(e2e): add HttpAgent keepAlive test (#472)#1267

Merged
chimurai merged 1 commit into
masterfrom
test-keepalive-agent
Jun 18, 2026
Merged

test(e2e): add HttpAgent keepAlive test (#472)#1267
chimurai merged 1 commit into
masterfrom
test-keepalive-agent

Conversation

@chimurai

@chimurai chimurai commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Add test for #472

Summary by CodeRabbit

  • Tests
    • Added end-to-end test for header mutation safety under concurrent keep-alive socket conditions.

@chimurai chimurai linked an issue Jun 18, 2026 that may be closed by this pull request
@pkg-pr-new

pkg-pr-new Bot commented Jun 18, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/http-proxy-middleware@1267

commit: 66948bc

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8e5abb99-9af1-4d15-86b4-45dbb12821cd

📥 Commits

Reviewing files that changed from the base of the PR and between 5b37301 and 66948bc.

📒 Files selected for processing (1)
  • test/e2e/http-proxy-middleware.spec.ts

📝 Walkthrough

Walkthrough

A new E2E test is added to verify header mutation safety under keep-alive socket contention (issue #472). It imports HttpAgent from node:http, creates a proxy with a shared keep-alive agent limited to a small socket pool, mutates a request header via on.proxyReq, and asserts that 20 concurrent requests all succeed with the correct header and no proxy errors.

Changes

Keep-alive header mutation E2E test

Layer / File(s) Summary
Keep-alive concurrency header mutation test
test/e2e/http-proxy-middleware.spec.ts
Adds HttpAgent import and a new E2E test that creates a proxied app with a shared keep-alive HttpAgent (constrained sockets), registers on.proxyReq to set a custom header, registers on.error to capture errors and emit HTTP 500, fires 20 concurrent GET requests, and asserts all responses succeed, no proxy errors occurred, and every upstream request received the mutated header. The agent is destroyed in a finally block.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hoppity-hop through the socket queue,
Twenty requests, all waiting in line,
The keep-alive agent shares its glue,
Headers mutate — and turn out just fine!
No proxy errors, the tunnel stays true,
Issue #472, farewell and goodbye! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding an end-to-end test for HttpAgent keepAlive functionality, directly addressing issue #472.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-keepalive-agent

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.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 95.183%. remained the same — test-keepalive-agent into master

@chimurai chimurai merged commit 22281bf into master Jun 18, 2026
25 of 26 checks passed
@chimurai chimurai deleted the test-keepalive-agent branch June 18, 2026 21:26
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.

ERR_HTTP_HEADERS_SENT from onProxyReq with keep-alive

2 participants