Skip to content

Fix balanced pool dns#4971

Open
Suleiman-KarimEddin wants to merge 3 commits intonodejs:mainfrom
Suleiman-KarimEddin:fix-balanced-pool-dns
Open

Fix balanced pool dns#4971
Suleiman-KarimEddin wants to merge 3 commits intonodejs:mainfrom
Suleiman-KarimEddin:fix-balanced-pool-dns

Conversation

@Suleiman-KarimEddin
Copy link
Copy Markdown

@Suleiman-KarimEddin Suleiman-KarimEddin commented Apr 4, 2026

This relates to...

Rationale

BalancedPool treated hostname upstreams as a single origin and did not spread new connections across all DNS records returned for that hostname. This change resolves hostname upstreams lazily at connect time and rotates connections across the resolved addresses without changing the synchronous BalancedPool API.

Changes

  • add lazy DNS resolution for hostname upstreams in BalancedPool
  • rotate new connections across all resolved DNS records
  • preserve logical hostname semantics for Host headers and TLS servername
  • add regression coverage for hostname upstream DNS balancing

Features

  • N/A

Bug Fixes

  • BalancedPool now balances hostname upstreams across resolved DNS records instead of reusing a single resolved address
  • requests continue to use the original hostname for Host and TLS servername while connecting through the resolved IPs

Breaking Changes and Deprecations

  • N/A

Status

Add lazy DNS balancing for hostname upstreams in BalancedPool.

When an upstream hostname resolves to multiple DNS records, new
connections now rotate across the resolved addresses instead of always
using a single result. This keeps the public BalancedPool API
synchronous while deferring DNS resolution until connection time.

Preserve the logical upstream origin so request Host headers and TLS
servername handling continue to use the original hostname rather than
the resolved IP address.

Also add a regression test covering hostname upstream balancing across
multiple resolved DNS records and verifying Host header preservation.
@mcollina
Copy link
Copy Markdown
Member

mcollina commented Apr 4, 2026

can you update the docs?

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.96%. Comparing base (9c24204) to head (2b89885).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4971   +/-   ##
=======================================
  Coverage   92.96%   92.96%           
=======================================
  Files         111      110    -1     
  Lines       35842    35843    +1     
=======================================
+ Hits        33320    33321    +1     
  Misses       2522     2522           

☔ 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.

Add regression coverage for hostname DNS balancing in BalancedPool,
including lookup errors, duplicate records, empty results, and the
all-clients-busy path.

Document that hostname upstreams are resolved lazily at connect time and
that requests preserve the original Host header and TLS servername.
Copy link
Copy Markdown
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

I think this would work better as an interceptor. IMHO balanced pool should be deprecated in favor of that.

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.

5 participants