Skip to content

test(http-proxy-middleware): avoid SuperTest listener warnings - #1297

Merged
chimurai merged 1 commit into
masterfrom
test-fix-MaxListenersExceededWarning
Oct 3, 2026
Merged

chimurai merged 1 commit into
masterfrom
test-fix-MaxListenersExceededWarning

Conversation

@chimurai

@chimurai chimurai commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Fix this warning in tests:

(node:1134) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 listening listeners added to [Server]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit

Problem: yarn test emitted Node MaxListenersExceededWarning messages during the concurrent socket-contention test.

Analysis: Twenty concurrent SuperTest requests shared a lazily started server. Each request registered listening, error, and close startup listeners before the server finished listening, exceeding Node's default listener limit.

Fix: Start the shared HTTP server before issuing the concurrent requests and close it in the test cleanup path. This preserves concurrency coverage while removing the startup-listener race.

Summary by CodeRabbit

  • Tests
    • Updated the keep-alive socket contention test to share one server across concurrent requests and close it during cleanup.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack β†’

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

βš™οΈ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a0a7eb90-ea6b-4f09-bc24-17a893713775
πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between f299080 and 859a174.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • πŸ” Trigger review

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3374e1d8-978d-4b9c-b2e3-c53b455c10c9
πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 543d749 and f299080.

πŸ“’ Files selected for processing (1)
  • test/e2e/http-proxy-middleware.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


πŸ“ Walkthrough

Walkthrough

The keep-alive socket contention test now sends concurrent SuperTest requests through an agent bound to one explicitly started HTTP server. The test closes that server in its finally block.

Changes

Proxy contention test

Layer / File(s) Summary
Shared server lifecycle
test/e2e/http-proxy-middleware.spec.ts
The test starts one HTTP server, waits for it to listen, and binds the request agent to it. The finally block closes the server and rejects if closing reports an error. Existing proxy error handling and assertions remain unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Merge Risk: βšͺ Minimal Β· up to f2990

The shared-server test addresses the startup-listener warning. The remaining narrow startup-error edge case does not block merging.

πŸš₯ 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 clearly identifies the test change and its purpose: preventing SuperTest listener warnings.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
✨ Finishing Touches πŸ’‘ 1
πŸ› οΈ Fix failing CI checks πŸ’‘
  • Commit to this branch
  • Create a new PR
πŸ“ Generate docstrings
  • Commit to this branch
  • Create a new PR
πŸ§ͺ Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot Β· Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Problem: yarn test emitted Node MaxListenersExceededWarning messages during the
concurrent socket-contention test.

Analysis: Twenty concurrent SuperTest requests shared a lazily started server.
Each request registered listening, error, and close startup listeners before the
server finished listening, exceeding Node's default listener limit.

Fix: Start the shared HTTP server before issuing the concurrent requests and
close it in the test cleanup path. This preserves concurrency coverage while
removing the startup-listener race.
@chimurai
chimurai force-pushed the test-fix-MaxListenersExceededWarning branch from f299080 to 859a174 Compare October 3, 2026 13:08
@pkg-pr-new

pkg-pr-new Bot commented Oct 3, 2026

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

commit: 859a174

@chimurai
chimurai enabled auto-merge (squash) October 3, 2026 13:09
@chimurai
chimurai merged commit cf713ad into master Oct 3, 2026
24 checks passed
@chimurai
chimurai deleted the test-fix-MaxListenersExceededWarning branch October 3, 2026 13:10
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 96.364%. remained the same β€” test-fix-MaxListenersExceededWarning into master

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